-
Notifications
You must be signed in to change notification settings - Fork 576
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
feat(isUtcLeap): Add function to determine a leap year in UTC to avoi… #3295
Conversation
…d timezone issues - Add isUTCLeap that is the same as isLeap but uses getUTCFullYear to avoid timezone issues - Add tests for isUTCLeap - Fix tests for isLeap that only failed on machines running in GMT-<anything>
TBH the whole idea of determining whether something's a leap year from a // in my current timezone, UTC+8
isLeap(new Date(2000, 0 /* zero-indexed month */, 1)) // true (consistently true everywhere)
isUTCLeap(new Date(2000, 0 /* zero-indexed month */, 1))) // false (but would be true if I lived somewhere with a zero or negative UTC offset)
isLeap(new Date("2000-01-01")) // true (but would be false if I lived somewhere with a negative UTC offset)
isUTCLeap(new Date("2000-01-01")) // true (consistently true everywhere) IMO it'd be better to simply deprecate or remove the |
I'm ok with either. I can update the PR if needed. How will I know if this is the way we want to go? Does a maintainer need to give the final say? |
I'd assume so — I'm just a random contributor so I can't speak authoritatively, just adding my 2 cents as I've come across far too many |
How come this functionality isn't being added to If a separate function is justified, it should be named Disclaimer: I have not looked at this implementation or discussion, so please excuse any ignorance. |
I could add an option object to is leap to toggle this feature but it seemed more idiomatic to make a second function to keep in line with the api of JavaScript's date object. This is also why I named the function the way I did. For more details see #3294. I'm not opposed to changing these details btw. I don’t feel very strongly about them. |
I see, I see. In that case, a separate function is reasonable. Again though, the function name would have to be |
I've changed the function to be named |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…d timezone issues
Implements #3294