-
Hey all, when using dateFns.parse to parse dates around the DST time: dateFns.parse("2022-03-13 02:30:00") I notice this results in the date being parsed backwards rather than forwards: Sun Mar 13 2022 01:30:00 GMT-0600 (Central Standard Time) Is this a bug, or is this intended? I would assume this should default to 3:30 rather than 1:30, as 2:30 is after 1:30 and in spring we skip the 2:00 hour and jump to 3:00. Thoughts? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This looks like
// in node.js
process.env.TZ = 'America/Chicago';
import { parseISO } from 'date-fns';
console.log(parseISO('2022-03-13 01:30:00').toString()); // Sun Mar 13 2022 01:30:00 GMT-0600 (Central Standard Time)
console.log(parseISO('2022-03-13 02:30:00').toString()); // Sun Mar 13 2022 03:30:00 GMT-0500 (Central Daylight Time)
console.log(parseISO('2022-03-13 03:30:00').toString()); // Sun Mar 13 2022 03:30:00 GMT-0500 (Central Daylight Time) |
Beta Was this translation helpful? Give feedback.
This looks like
date-fns
v1, which I think is unlikely to get any patches at this point (last release was in December 2018).parseISO
looks fine in v2 if you want to migrate: