Home > OS >  Timezone obtained via TimezoneFinder, 'America/Ciudad_Juarez', generates error UnknowTimeZ
Timezone obtained via TimezoneFinder, 'America/Ciudad_Juarez', generates error UnknowTimeZ

Time:12-16

I retrieve timezones from airports of the world, using TimezoneFinder().timezone_at applied on longitude and latitude of airports. And when I want to use these timezones (to compute times of departure ad arrival of flights) everything works except America/Ciudad_Juarez. This simple code:

from timezonefinder import TimezoneFinder
from pytz import timezone
tz = TimezoneFinder().timezone_at(lng=-106.48333, lat=31.73333)
# retrieves 'America/Ciudad_Juarez'
timezone(tz)

Generates this error:

UnknownTimeZoneError: 'America/Ciudad_Juarez'

I checked in this excellent wikipedia page, this timezone is correct, canonical they say. I am surprised that a timezone obtained through timezonefinder is not recognised by pytz. How can I cleanly solve this?

CodePudding user response:

This timezone was only very recently added, as Ciudad Juárez decided to align it's time with the US for DST. See http://mm.icann.org/pipermail/tz-announce/2022-November/000076.html for the announcement. It looks like pytz has not been updated to include that change just yet.

CodePudding user response:

pytz is deprecated. No issues with Python 3.9 zoneinfo:

from datetime import datetime
from zoneinfo import ZoneInfo

print(datetime.now(ZoneInfo("America/Ciudad_Juarez")))
# 2022-12-15 12:14:07.369739-07:00

(Python 3.9.15 on GNU/Linux)

  • Related