New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'Invalid time zone specified' when calling formatInTimeZone with time zone offset and time zone tokens #186
Comments
After a little more research, it looks like maybe it's not possible to convert a numerical offset to a named offset |
|
I will take a look. If you have the time, a PR with failing unit tests will help me sort this out quicker. |
Here you go! #187 |
@dancornilov you have to specify the IANA time zone name: |
Closing this, continued in #187. |
Hey, we've been getting hundreds of Sentry errors related to this issue but are quite stuck on how to approach this. It seems like the time zone name is definitely in IANA. Our largest customer group is in Iceland and we've been getting: But also for
We're calling formatInTimezone based on the "company" timezone: export const getCompanyTimezone = () => {
const company = getCompany();
const companyTimezone = company?.connections.location?.timeZone;
if (companyTimezone && isValidTimezone(companyTimezone)) {
return companyTimezone;
}
return getUserTimezone();
}; Here's the const isValidTimezone = (tz: string) => {
if (!Intl?.DateTimeFormat().resolvedOptions().timeZone) {
// This one has never been reported
Sentry.captureException(new Error('Intl.DateTimeFormat().resolvedOptions().timeZone is undefined'), {
extra: {
tz,
resolvedOptions: JSON.stringify(Intl.DateTimeFormat().resolvedOptions())
}
});
return false;
}
try {
Intl.DateTimeFormat(undefined, { timeZone: tz });
return true;
} catch (ex) {
return false;
}
}; I'm not sure how to approach this so any help is much appreciated ❤️ |
Hey @gunnartorfis, did you end up solving this issue? |
Given the following documentation (emphasis mine):
I expect the following to work:
What actually happens:
To reproduce, run the code in this Replit Repl
The text was updated successfully, but these errors were encountered: