In Elixir core is there a function to check if a given timezone is valid?
I’m mainly looking at DateTime and Calendar but as far as I can tell they both don’t have a way to directly verify that a given String is a valid time zone.
I think there’s two options here:
- A: Use a function like
DateTime.now/1and check if it returns{:error, :time_zone_not_found} - B: Directly use a time zone library like
tzortzdata
I suppose A is the way to go and is not that odd. But it does feel a little weird that there isn’t a way to directly check the validity of a timezone. And it looks like that function can only return two errors {:error, :time_zone_not_found | :utc_only_time_zone_database} so as long as I ensure that I setup my time zone database correctly I can use DateTime.now/1 to check the validity of a time zone.






















