Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implicit 0's behaviour-change #90

Closed
valentinradu opened this issue Feb 2, 2019 · 4 comments
Closed

implicit 0's behaviour-change #90

valentinradu opened this issue Feb 2, 2019 · 4 comments

Comments

@valentinradu
Copy link

spacetime('2019-01-25T20:00:00+01:00').isBefore('2019-01-25T20:00:00+01:00') returns true, but clearly is the same date. Prob is, when milliseconds are not specified, the parser doesn't assume 0, but a random (prob taken from current date) value.

@spencermountain
Copy link
Owner

good find!
will fix it today, thanks.

@spencermountain
Copy link
Owner

fixed in 5.2.2.

yeah, I don't mind the idea of using implicit values from the current time -
if you say spacetime('june 5th 2018') i don't mind setting the current hour, minute, etc.

Those are the same assumptions made in js date object.

But if this generates race-conditions, like your example, we should avoid those, at least.

I've co-erced millisecond, and second to 0, unless they're specified.
Minutes and hours will be left unchanged.

It's possible that if you run this on the last millisecond before a minute changes, it'll happen again.

¯_(ツ)_/¯
thanks

@hunteva
Copy link
Contributor

hunteva commented Feb 5, 2019

Thanks for the fix @spencermountain but I'm afraid js date doesn't make that assumptions.

> new Date('June 5 2018')
2018-06-04T12:00:00.000Z
> new Date('2018-06-06')
2018-06-06T00:00:00.000Z
> new Date(2018, 05, 05)
2018-06-04T12:00:00.000Z
> new Date()
2019-02-05T01:42:51.432Z

except there is no arguments passed in, feels it might be nicer to have the same behaviour as js date object, I could make those changes if you like.

@spencermountain
Copy link
Owner

oh hey, good point!
i'll reopen this.

@spencermountain spencermountain changed the title Wrong isBefore return value when missing milliseconds in the date implicit 0's from js Date Feb 5, 2019
@spencermountain spencermountain changed the title implicit 0's from js Date implicit 0's behaviour-change Feb 5, 2019
spencermountain added a commit that referenced this issue Feb 8, 2019
Fix for #90 and also the dst awareness add function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants