You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because time manipulation methods like addHours use set methods like setHours, crossing DST results in unexpected times.
Example:
In New York, DST starts on March 12 at 2am, skipping the hour between 2am and 3am. If you add 3 hours to the start of the day, it should return 4am (midnight + 3 hours, skipping 2am). date-fns returns 3am because it calls setHours(3).
Solution:
Instead of using setHours, date-fns should add milliseconds to the given Date object: new Date(date.getTime() + hours * 3600000)
The text was updated successfully, but these errors were encountered:
Because time manipulation methods like
addHours
useset
methods likesetHours
, crossing DST results in unexpected times.Example:
In New York, DST starts on March 12 at 2am, skipping the hour between 2am and 3am. If you add 3 hours to the start of the day, it should return 4am (midnight + 3 hours, skipping 2am). date-fns returns 3am because it calls
setHours(3)
.Solution:
Instead of using
setHours
, date-fns should add milliseconds to the given Date object:new Date(date.getTime() + hours * 3600000)
The text was updated successfully, but these errors were encountered: