Closed wundersolutions-juanjo closed 9 months ago
Just had same observation. Day of week is not returning correct value:
Would be nice if this could get a hotfix
my current workarround:
const dayIntl: Intl.DateTimeFormat = new Intl.DateTimeFormat('en-GB', { weekday: 'short' } as Intl.DateTimeFormatOptions);
const day: 'Sun' | 'Mon' | 'Tue' | 'Wed' | 'Thu' | 'Fri'| 'Sat' = dayIntl.format(temporalDate) as 'Sun' | 'Mon' | 'Tue' | 'Wed' | 'Thu' | 'Fri'| 'Sat';
return [ '', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' ].indexOf(day);
I see what's going on here. The code is internally leveraging a zoned Date method (.getDay()) when it shouldn't be. This gives eradic results based on the current user's timezone. I'll get this fixed+released today.
This is fixed in v0.2.1
Turns out I was incorrectly leveraging the timezone-sensitive Date::getDay()
AND I had an off-by-one error when computing days-of-week, and the two bugs cancelled each other out for my particular timezone and the time of day I normally work, so I never experienced the bug (nor my CI). Fun.
@digaus and @wundersolutions-juanjo could you kindly check to see if things work in your timezone (even tho timezone should not matter)
Yeah timezone should not matter but I can confirm, that it works now correctly with dayOfWeek
Looks good, both for #26 and #27, thank you very much!
In the current 0.2.0 version of the polyfill, PlainDate.dayOfWeek is not returning the correct value for ISO 8601 calendars
From the current docs on PlainDate,
Testing that on a website using the https://cdn.jsdelivr.net/npm/temporal-polyfill@0.2.0/global.min.js polyfill results on dates being one day off