-
Notifications
You must be signed in to change notification settings - Fork 171
Description
console.log(Temporal.PlainDate.from('2011-12-30').toLocaleString('en-US'));
console.log(new Intl.DateTimeFormat('en-US').format(Temporal.PlainDate.from('2011-12-30')));The result I expected is "12/30/2011". But when the system time zone is "Pacific/Apia" (Samoa's standard time zone), all results above will be "12/31/2011", which means 2011-12-31, not original 2011-12-30. I confirmed this behavior in reference polyfill, V8, and SpiderMonkey. I think it also matches the current spec.
Samoa's case is a bit extreme (an offset transition of 24 hours skip), but the same thing also happens to all Temporal.PlainDateTime which corresponds to any DST gaps in the system time zone.
I was very surprised and feel this is very confusing, because I thought Temporal APIs would behave independently from the system time zone except explicit APIs related to Temporal.ZonedDateTime.
Note that I'm not sure what is the desirable behavior when the timeZone option is specified like below.
// should throw an error, or ignore `timeZone` option?
console.log(Temporal.PlainDateTime.from('2011-12-30').toLocaleString('en-US', { timeZone: 'Pacific/Apia' }));
console.log(new Intl.DateTimeFormat('en-US', { timeZone: 'Pacific/Apia' }).format(Temporal.PlainDateTime.from('2011-12-30')));