question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Timezone startOf DST off-by-one

See original GitHub issue

In Australia DST ends on the 4th of April 2021.

Using the timezone plugin and v1.10.4 (latest):

  • Getting the start of the day before this date (in DST) returns the correct value
  • Getting the start of the day after this date (outside DST) returns an incorrect value.
dayjs.tz('2021-04-01 08:00', 'Australia/Melbourne').startOf('day').format()
// 2021-04-01T00:00:00+11:00 (correct)

dayjs.tz('2021-04-15 08:00', 'Australia/Melbourne').startOf('day').format()
// 2021-04-14T23:00:00+11:00 (incorrect)

Curiously, the changelog mentions this issue was fixed in v1.9.7, so I switched to 1.9.6 to test this and it seems to be working correctly:

dayjs.tz('2021-04-01 08:00', 'Australia/Melbourne').startOf('day').format()
// 2021-04-01T00:00:00+11:00 (correct)

dayjs.tz('2021-04-15 08:00', 'Australia/Melbourne').startOf('day').format()
// 2021-04-15T00:00:00+11:00 (correct)

Is anyone up for fixing this? I’ll throw a $100 bounty down. Surely there are some others who also need this fixed and want to add to the pool!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:16
  • Comments:16

github_iconTop GitHub Comments

6reactions
ashconnellcommented, May 27, 2021

@apm78 day-js timezone support is insanely broken.

The docs make it seem like timezone support is production ready but it’s literally a single ~80 line file that barely covers anything.

I’m not very knowledgeable with timezones so it’s hard for me to contribute, but strategically I think this repo should:

  1. Make it blatantly obvious that timezone support isnt ready to be used
  2. Build a test suite that cross checks results with something that is production ready, eg Moment.js

I spent literally weeks adding day-js to a new platform before realising these issues existed and then spent literally days swapping it back out for Moment.js

4reactions
nemphyscommented, Apr 7, 2021

@iamkun do you have any ETA plans for a new release? The dev branch contains a commit that fixes a pretty bad timezone issue with DST. AFAICT there’s no historical release that has stable timezones except the upcoming one.

+1 on this, would have to have to revert to moment.js because of this!

Read more comments on GitHub >

github_iconTop Results From Across the Web

KB914387: How to configure daylight saving time for Microsoft ...
Click Start, click Run, type control timedate.cpl,,/Z, and then press Enter. Click the Time Zone tab, select the (GMT-08:00 Pacific Time (US &...
Read more >
Daylight Saving Time – DST – Summer Time - Time and Date
When clocks go forward one hour in the spring and back one hour in the fall, it's known as Daylight Saving Time (DST),...
Read more >
Working With Time Zones And Daylight Savings Time (DST) In ...
The day after daylight savings time has been put into effect in Mountain time, the two time zones are off by one hour,...
Read more >
Event Invite Time Shown is off by One Hour - Mozilla Support
The following is that start of the invite.ics file: ... that it is something to do with DST, but have no idea how...
Read more >
Temporal Cookbook - TC39
See also Push back a launch date for an easier way to round up unconditionally to the next start of a month. Time...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found