9 ms·
Timezones! Actual jurisdictional timezones, as in tzdata’s Europe/Lisbon! Hooray! https://www.python.org/dev/peps/pep-0615/#id7 https://www.python.org/dev/pe
by gorgoiler 6y ago
Timezones! Actual jurisdictional timezones, as in tzdata’s Europe/Lisbon! Hooray!
https://www.python.org/dev/peps/pep-0615/#id7 https://www.python.org/dev/peps/pep-0615/#id7
- gojomo 6y agoIs there a backport for earlier Python 3.x versions?
- x1798DE 6y agoYes: https://pypi.org/project/backports.zoneinfo/ https://pypi.org/project/backports.zoneinfo/
- tialaramex 6y agoYes! The Olson Database is the Right Thing™. Timezones are a weird human artefact, but ordinary humans have no idea what ZQMT or whatever actually "is" and will make loads of egregious mistakes if exposed to these zones directly even if your UX isn't terrible (which it probably will be). But humans do understand what a city is, and if they live in or near one they understand what the time is in that city, adjusting for any weird local political rules like "Daylight saving" because those rules affect their life. It's the right granularity practically too. Can politicians decide that Dublin and Belfast are in different timezones? Yeah, it'd be difficult but I think they could make that happen. How about Queens and Brooklyn? Ahahaha No. The residents will defy any pretence that clocks change between one city block and the next, it would never stick.
- IgorPartola 6y agoYes. When applications ask me what timezone I am in and simply give me the offset I get very nervous. Especially since they are usually event scheduling or email sending services where timing actually matters a lot.
- JetSpiegel 6y ago> The residents will defy any pretence that clocks change between one city block and the next, it would never stick. Going from the example of "Europe/Lisbon", Valença and Tui have 1h of difference, but are located on the same longitude, <3km from one another... - https://en.wikipedia.org/wiki/Valen%C3%A7a,_Portugal https://en.wikipedia.org/wiki/Valen%C3%A7a,_Portugal - https://en.wikipedia.org/wiki/Tui,_Pontevedra https://en.wikipedia.org/wiki/Tui,_Pontevedra
- wasmitnetzen 6y agoAnd on different sides of a border. I'm not sure what point you are making, that case happens all the time where two timezones meet.
- JetSpiegel 6y agoThis is an inner EU border, so similar to Phenix City[1] mentioned above. Many people live and work on different sides of the border, but they just accept things as-is. [1]: https://en.wikipedia.org/wiki/Phenix_City,_Alabama https://en.wikipedia.org/wiki/Phenix_City,_Alabama
- jcranmer 6y agoThere is a problem with the timezone database, which is that it can be a little too granular, since it defines a timezone as all places that share the same clocks since the Unix epoch. This means that if jurisdictions decide to move from one timezone to another, they each get their new timezones. Take Indiana. Indiana is in the US Eastern time zone, except for some places near the Illinois border, which are US Central. But Indiana also didn't observe DST until 2006 (although some counties did observe DST). Consequently, what could generally be described as three timezones (as in the MS timezone selector) is actually described as 11 timezones: https://en.wikipedia.org/wiki/Time_in_Indiana#tz_database https://en.wikipedia.org/wiki/Time_in_Indiana#tz_database From what I understand, locals in Indiana actually refer to time simply as Eastern or Central (with non-observance of DST meaning you shift from Eastern in winter to Central in summer).
- Diederich 6y agoCurious thing. The Chattahoochee River divides the US states of Alabama and Georgia, the former being on Central time and the latter being on Eastern time. There's a city in Georgia called Columbus, and it's right up against the river, and so is adjacent to Alabama and Central time. Years ago we visited my wife's family in Columbus with some frequency, once we visited the Wal-Mart supercenter in Phenix City (yes, it's spelled way wrong) Alabama, which is right on the eastern border of Alabama, also next to the river. Since I worked in Wal-Mart Information Systems at the time, I had quite a bit of access and noted that the store's systems were on Eastern time, even though the entire state of Alabama is on Central. Sure enough: https://en.wikipedia.org/wiki/Phenix_City,_Alabama https://en.wikipedia.org/wiki/Phenix_City,_Alabama "Phenix City lies immediately west across the Chattahoochee River from the much larger Columbus, Georgia and observes Eastern Time on a de facto basis (in contrast to the rest of Alabama, which observes Central Time) due to Phenix City's strong economic ties to Columbus." The Olson Database is amazing; I've non-trivially interacted with it a number of times in my career. Even so, the final, on the ground authority is the people who use and are affected by time zones.
- IgorPartola 6y agoThis is really exciting. I didn’t find much else in terms of features that caught my eye but this is really neat.
- globular-toast 6y agoCool. Will this obsolete pytz I wonder? It does seem like quite an important thing to be in the standard library given the kind of things Python is used for. It's amazing how few developers actually understand timezones. I found the Pendulum library [0] very intuitive when it comes to working with time. It makes it easy to do the right thing. For example, if you call `pendulum.now` it gives you a timestamp including your local timezone information. In other words, it preserves "the time on the clock on the wall", which is lost if you do what so many people do and just take UTC timestamps. pendulum.now() # DateTime(2020, 5, 28, 13, 32, 1, 303100, tzinfo=Timezone('Europe/London')) Doing this in the standard library, or with pytz, is very unintuitive and often done incorrectly in practice. [0] https://pendulum.eustace.io/ https://pendulum.eustace.io/