GithubHelp home page GithubHelp logo

Comments (5)

davidkaneda avatar davidkaneda commented on May 24, 2024 1

@tkreis I implemented some tests locally to better test for invalid strings, and your fix mentioned above (which is accurate), but it breaks the following two tests: "this year" and "this month."

I tend to think date.js in general could benefit from some more direction in regard to the purpose of the library, which, as I see it, is to provide an exact timestamp from a fuzzy bit of language. If this is the case, "this year" and "this month" should probably be removed anyway, as they're too ambiguous. Same with items like #11. On the other hand, the lib itself should probably support "Now."

Any thoughts?

from date.

ianstormtaylor avatar ianstormtaylor commented on May 24, 2024 1

+1 this is frustrating when you want to specifically only parse with Date.js when it's able to do it, and otherwise fallback to something else.

from date.

matthewmueller avatar matthewmueller commented on May 24, 2024

hmm, I think this line covers this case:

https://github.com/MatthewMueller/date/blob/master/lib/parser.js#L50

Basically if the date hasn't changed at all, throw an error (in line with the Date(invalid) does). I'm not sold on throwing an error, we could maybe go with null instead. What's the input that you're using?

from date.

dominictarr avatar dominictarr commented on May 24, 2024

ah, I noticed that in the code, but I couldn't get it to throw.
I tested this with nonsense 'aoneuhracr', but it returns the current time.

from date.

tkreis avatar tkreis commented on May 24, 2024

@matthewmueller If your intent was to compare dates it won't work, if your intent was to compare objects it works. By changing the line to it'll compare if the dates are actually the same.

d.getTime() == this.date.date.getTime()

from date.

Related Issues (20)

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.