Giter Club home page Giter Club logo

Comments (5)

JackStouffer avatar JackStouffer commented on August 30, 2024

@WebFreak001 The reason the code gets confused is that it sees two different timezones in the string. From it's perspective, you're asking for a date which is in both the GMT+0100 timezone and in the Central European Standard Time timezone.

This format is a really odd corner case, so your best option (if you can't change your inputs to something else) is to turn on fuzzy matching and then rely on the GMT auto-timezone parsing. So it would be

parse(
    "Thu Nov 07 2019 17:00:00 GMT-0100 (UTC)",
    No.ignoreTimezone,
    null,
    No.dayFirst,
    No.yearFirst,
    Yes.fuzzy
);

which gives you the correct result.

from date-parser.

WebFreak001 avatar WebFreak001 commented on August 30, 2024

uh where did you get the GMT-0100 (UTC) from? I was only talking about matching timezone & offset names which seem to be generated from some kind of library in the wild, which I found when parsing some RSS feeds.

from date-parser.

JackStouffer avatar JackStouffer commented on August 30, 2024

Sorry, it was from a test I was writing. But the point remains. With the string

Thu Nov 07 2019 17:00:00 GMT+0000 (UTC)

The code doesn't hardcode the name of timezones other than GMT, so it sees two timezones defined at once: GMT+0000 and UTC.

from date-parser.

WebFreak001 avatar WebFreak001 commented on August 30, 2024

I believe the stuff in () is just a comment which should be ignored by parsing apps, but I don't know in which standard that is specified. At least that's how the JS Date API works

from date-parser.

JackStouffer avatar JackStouffer commented on August 30, 2024

Looks like this is the standard output of the JavaScript Date.toString method.

From this library's perspective, I don't think I can assume that any text inside of a () should act as a comment. I can easily imagine some weird date format like the following

Jan 3, 2020  8:30 AM (EST)

where stuff inside of the parentheses is relevant to the result.

I'm going to close this and suggest that you turn on fuzzy matching, which is designed to handle formats like this. If this does not give the correct result please let me know.

from date-parser.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.