Skip to content

dateFns.parse for DST dates parses in the incorrect direction #3107

Answered by fturmel
panzey asked this question in Q&A
Discussion options

You must be logged in to vote

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:

// 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)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by panzey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants