Comments (5)
@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.
+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.
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.
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.
@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)
- post meridiem is ignored in `"at 3:00 p.m."`, but not in `"at 3:00 pm"`
- Why are you returning a default date when the supplied input is invalid? HOT 1
- Unofficial date.js has new v4.0.0 - possible malware
- How to get start and end date of current month and week?
- function to determine if an input is valid or not
- var _year = 56 * _week
- Add TypeScript support
- Fixes with NLP HOT 2
- Decimal values cause unexpected results
- "100 days ago" not working HOT 5
- Return error if date not understood HOT 2
- '100 days from now' not working HOT 1
- Security Vulnerability in npm package
- Querying 'next monday' on a monday gives you today, when it should return next week's monday
- Error using standalone file in dist HOT 3
- Today is tomorrow HOT 1
- 'at 6.09am' does not work but 'at 6:09am does'
- in 120 seconds return wrong time. HOT 1
- date is undefined: can't import module HOT 1
- date("30 days ago at 18:00") gives date which is 1 month ahead in nodeJS. (instead of 1 month old date)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from date.