dayjs
dayjs copied to clipboard
Got 'Etc/Unknown' after calling dayjs.tz.guess
Describe the bug Got 'Etc/Unknown' after calling dayjs.tz.guess
Expected behavior A right time zone. Under what circumstances would this result be obtained?
Information
- Day.js Version [^1.11.7]
Etc/Unknown
timezone states that timzone information cannot be determined based on user's preferences.
Given that Etc/Unknown
can be returned from .guess
, my app is getting a bug with a user when we use .format('L LT z')
-- presumable from how this calls Intl.DateTimeFormat with an unknown timezone.
It would be great if dayjs handled this gracefully! I intend to have a try/except in my code to handle.
+1 - would be great to provide a fallback (for example to UTC) when a Timezone can't be determined
Now fixed it this way in my Vue application:
const currentTimezone = ref(dayjs.tz.guess() !== 'Etc/Unknown' ? dayjs.tz.guess() : 'UTC');