Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Pytz have different timezone listings for New York and Detroit?

>>> pytz.country_timezones['US']

America/New_York
America/Detroit
America/Kentucky/Louisville
America/Kentucky/Monticello
America/Indiana/Indianapolis
America/Indiana/Vincennes
America/Indiana/Winamac
America/Indiana/Marengo
America/Indiana/Petersburg
America/Indiana/Vevay
America/Chicago
America/Indiana/Tell_City
America/Indiana/Knox
America/Menominee
America/North_Dakota/Center
America/North_Dakota/New_Salem
America/North_Dakota/Beulah
America/Denver
America/Boise
America/Phoenix
America/Los_Angeles
America/Metlakatla
America/Anchorage
America/Juneau
America/Sitka
America/Yakutat
America/Nome
America/Adak
Pacific/Honolulu

From everything I can find online, there is absolutely no difference between New York and Detroit timezones, including DST. And this was just from checking the first two. They've gotta have a reason for having both, right?

edit: expanding on my research, all the timezones listed which are UTC -5 have the same exact DST info, so it seems even more redundant now. I could remove all the below with one for Eastern Standard Time... Is there anything wrong with doing that?

(UTC -5:00) New_York
(UTC -5:00) Detroit
(UTC -5:00) Kentucky/Louisville
(UTC -5:00) Kentucky/Monticello
(UTC -5:00) Indiana/Indianapolis
(UTC -5:00) Indiana/Vincennes
(UTC -5:00) Indiana/Winamac
(UTC -5:00) Indiana/Marengo
(UTC -5:00) Indiana/Petersburg
(UTC -5:00) Indiana/Vevay
like image 502
Chockomonkey Avatar asked Nov 21 '14 21:11

Chockomonkey


People also ask

How do I get all the time zones in pytz?

Get List of All Timezones Name. First, Install the pytz module if not installed using the pip install pytz command. Use the pytz. all_timezones attribute to get the list of available timezone in the world.

What is pytz timezone?

pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher. It also solves the issue of ambiguous times at the end of daylight saving time, which you can read more about in the Python Library Reference ( datetime.

Does pytz handle DST?

Localized times and date arithmetic This library also allows you to do date arithmetic using local times, although it is more complicated than working in UTC as you need to use the normalize() method to handle daylight saving time and other timezone transitions.

Is EST and NYT the same?

EST is half of the New York time zone, effectively. It's always in standard time - it doesn't have the daylight saving part. It's not really a proper time zone in its own right, IMO - it's the "standard" part of a fuller time zone.


2 Answers

Pytz uses the IANA time zone database (also known as the Olson database). As @brenbarn mentions, time zones in the IANA database reflect "any national region where local clocks have all agreed since [January 1st] 1970.", which includes not only time but DST changes as well.

According to the database, "Most of Michigan observed DST from 1973 on, but was a bit late in 1975." So this means that in 1970 Michigan was on EST, while the east coast observed Daylight Savings Time. Additionally DST did not start on 1975 in Michigan until April 27th, a few weeks after the rest of the Eastern time zone.

If you download the most recent files, there should be various files (northamerica, southamerica, africa, etc.) which have human-readable descriptions of what the different time zones are, and explanations of any changes / reasons why they are not in a different time zone.


To build on your edit, Indiana represents a special case within the US, due to its historical presence at the boundary line between two time zones. As of November 2014, Indiana is mostly in the Eastern Time Zone (save for a few counties near Chicago and near Evansville, which are in central time), and the entire state observes Daylight Savings Time. But the Central/Eastern boundary has shifted quite a few times since 1970. In fact, I bet a majority of those time zones happened when a number of counties switched zones in 2006 and again in 2007, adopting Daylight Savings Time in the process.

like image 175
Roger Filmyer Avatar answered Sep 22 '22 10:09

Roger Filmyer


pytz uses the zoneinfo timezone definitions, which apparently define a time zone as "any national region where local clocks have all agreed since 1970." I would suspect that historical changes in time zone or daylight savings behavior have resulted in locations that currently have the same time but didn't always. (For instance, I think Boise and Denver are also equal timewise now, but they also have different entries.)

like image 29
BrenBarn Avatar answered Sep 19 '22 10:09

BrenBarn