0

I'd like to be able to tell if a user is in Canada and show an English-French language toggle for those users. So I've decided to use the Intl.DateTimeformat.resolvedOptions approach. It's pretty straightforward, if the user's system is says it's in a Canadian time-zone, then I want to respect that and assume they want to see this Canadian option. You can see a working demo below:

const obj = Intl.DateTimeFormat().resolvedOptions();
console.log("Locale: ", obj.locale);
console.log("TimeZone: ", obj.timeZone);

I've asked some friends to test it, and so far I've got 2 timeZones

  • America/Toronto
  • America/Vancouver

but I need to cover all the Canadian options. I've looked at the ECMA internationalization API and IANA TimeZone Database but I cannot find what I'm looking for because their documentation is too vast. What are all the possible Canadian timezones that I could get from this specification?

M -
  • 26,908
  • 11
  • 49
  • 81
  • [wikipedia](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). Also see: [Valid IANA timezone list](https://stackoverflow.com/questions/66490421/valid-iana-timezone-list) – pilchard Jul 20 '22 at 21:38
  • Note: it may be a bad idea. Something like default values are ok, but not displaying something according settings (which sometime are not controlled by users) is bad. A Canadian which work for some US company may have US time, but such user may want to see French. Or also a Canadian in US. As a user, I find very annoying when a system want to be smart, but it is not (hey Google!) – Giacomo Catenazzi Jul 21 '22 at 09:17

0 Answers0