spencermountain / spacetime

A lightweight javascript timezone library
http://spacetime.how/
Other
3.97k stars 184 forks source link

Spacetime not working in MacOS Sonoma (Cannot find timezone named: 'cet'. Please enter an IANA timezone id) #397

Closed trocoli96 closed 10 months ago

trocoli96 commented 10 months ago

When updating the OS to the new MacOS Sonoma (now in beta) the spacetime constructor fails because taking the browser timezone is not a IANA timezone. For example:

In Europe:

Intl.DateTimeFormat().resolvedOptions().timeZone

Before: 'Europe/Madrid'

Now: 'CET'

So this results on spacetime failing image

If this is happening on the OS level it may affect other regions in the world too.

eaarranz commented 10 months ago

We may help you with the implementation if you consider that it should be fixed ;) Maybe you should allow the same approach that you use at timezones-soft in the lookupTz function or add cet and cest as aliases, but we should explore if it happens elsewhere.

spencermountain commented 10 months ago

oh my gosh - thank you for the heads-up. Is this documented anywhere? Yeah, I'm happy to fix this asap. Yep, at minimum we can add a guard to prevent the runtime error. Please let me know if you can dig anything up about this change. I can't believe they're returning non-IANAs. oof! thank you.

eaarranz commented 10 months ago

Since the heads up from one of our customers, we have been trying to reproduce it, and we were able to reproduce it with the last beta updating one of our laptops. At least here where we were getting 'Europe/Madrid', we are getting 'cet'; configuring the timezone manually to 'Europe/Madrid' does not change it back to 'Europe/Madrid' and keeps returning 'cet.'.

We did not find any documentation regarding it... But we are kind of lost on where Apple tracks these types of changes.

Since you have the aliases, maybe we can extend them to include cet, met, eet and wet and use them to check if the returned value of Intl.DateTimeFormat().resolvedOptions().timeZone is an alias and return the IANA value of them.

spencermountain commented 10 months ago

thank you. Yup - I will release a hotfix this afternoon. appreciate the help.

eaarranz commented 10 months ago

I will open a bug to Apple as feedback for Sonoma; at least we'll know if it's something planned or needs fixing on their side.

spencermountain commented 10 months ago

ok - released a fix for this as 7.4.7 - but would love some help testing it against any variants of this.

Yeah - turns-out there's even-weirder responses than 'CET' from the Intl api, apparently you can get the result 'Factory'. No idea how, but it appears in:

Intl.supportedValuesOf('timeZone')

I added a test for the Node 18, and Firefox results, but I'm sure there's more to be found. I aliased them to whatever it said in wikipedia. - but please let me know if I've done something foolish. There's always a good chance of this. cheers

eaarranz commented 10 months ago

I'll take a look at both the supported values that I get on Chrome and the values that we get on Sonoma.