-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Getting wrong startOf('day') in a different timezone #1212
Comments
I have a reproduction for this in the dayjs test suite, but I'm not sure how to fix it. Here is how I reproduced it in it('startOf day across timezones', () => {
const originalDay = dayjs('2010-01-01T00:00:00Z').tz('UTC')
const startOfDay = originalDay.startOf('day')
expect(startOfDay.valueOf()).toEqual(originalDay.valueOf())
}) (I also had to extend I'm going to keep at this and see if I can come up with a fix, but if a maintainer has an idea I'd love to hear it since I'm not very familiar with the dayjs internals. |
I meant to paste the output from this test, sorry about that. Here it is:
|
🎉 This issue has been resolved in version 1.9.7 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Describe the bug
On calculating startOf('day') in a different timezone, I am getting the wrong result. Note that I tried this at 6 PM on November 12 in Asia/Kolkata timezone.
Code -
dayjs.tz(new Date()).tz('America/New_York').startOf('day').toString()
Result -
"Thu, 12 Nov 2020 15:30:00 GMT"
Expected behavior
It should be
Thu, 12 Nov 2020 05:00:00 GMT
Information
The text was updated successfully, but these errors were encountered: