dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

Got 'Etc/Unknown' after calling dayjs.tz.guess

Open Adophlidu opened this issue 1 year ago • 3 comments

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]

Adophlidu avatar Jan 22 '24 03:01 Adophlidu

Etc/Unknown timezone states that timzone information cannot be determined based on user's preferences.

Loori-R avatar Feb 02 '24 16:02 Loori-R

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.

ZoomIsland avatar Mar 05 '24 00:03 ZoomIsland

+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');

christianschoenmakers avatar Jul 24 '24 10:07 christianschoenmakers