Handling Date and Time is Complicated
Today, a new commit was made to the Python tzdata package. What package is this and what was the change? Here is the story.
Python's tzdata module contains the timezone database which has all the different the timezones for each region as well as information on the start and end of daylight savings time for the regions.
Three days ago, the Mexican senate passed a bill abolishing daylight savings time. The law goes into effect on October 30th. So, if you have any python code which might use dates in spring/summer 2023, you need to upgrade tzdata to the latest version right now to get the latest timezone database or all your times will be off by an hour.
After this change, Mexico will have no daylight savings time. But its more complicated than that. Northern regions of Mexico sync their clocks with time of the adjoining US state, NOT with the national Mexican time. And since US observes daylight savings, these regions will also continue to observe DST even after Mexico abolishes DST.
But thats not all - the northern Mexican state of Sonora syncs its time with the US state of Arizona. Arizona is an exception in the US and does NOT observe daylight savings.
Confused? Any python code that works with times and dates has to get all this right.
Bottom line, you will need to upgrade your tzdata package, or you are going to run into problems.
But that's not all. These kinds of changes are happening all the time. Many regions are constantly starting or abolishing daylight savings, or changing the start or end days when daylight saving goes into effect or even changing the timezones.
If you have been following the cricket T20 world cup going on in Australia, you might have realised that Brisbane local time is one hour behind Melbourne local time, even though Brisbane is actually EAST of Melbourne. That's because Queensland does not observe daylight savings, but Victoria does.
Working with time, dates, timezones and daylight saving is one of the most challenging parts of programming.
Some strange timezones
If you thought the situation where regions in Mexico follow different timezones of other countries was strange, then check out some of these "interesting" timezones. Hope your app handles them properly :)
- In the article mentioned above, I said that the US state of Arizona does not follow daylight savings time. This is not completely true. The northern part of Arizona is Navajo Nation, an area reserved for the Native American Navajo people, and that region of Arizona follows daylight savings just like the rest of the US.
- The story doesn't end there. Contained within the Navajo Nation is an area for the Hopi Nation, another of the Native American tribes. Hopi Nation follows Arizona rules and does not observe daylight savings. And contained within Hopi Nation, is a small village of Navajo which... you guessed it, follows daylight savings.
- One region of Australia follows a unique timezone with a 45 minute offset: Australia Central Western Time is UTC+8:45. And Nepal is 15 minutes ahead of India with UTC+5:45 timezone.
- Morocco follows permanent daylight savings time the whole year round. But during the month of Ramadan, daylight savings is suspended and the country reverts to standard time. Once Ramadan is over, daylight savings resumes.
- Finally, a unique case of an informal timezone. Tea plantations in the North East of India follow "Chaibagaan Time" which is 1 hour hour ahead of Indian Standard Time. This timezone is followed only within the tea plantations, so when you enter the plantation you adjust your watch one hour forward and when you leave the plantation you adjust the watch an hour behind. Two people talking across the fence of the tea plantation would have a one hour difference in time.