question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fixing the mess 3.0 put me in

See original GitHub issue

It’s become clear to me that 3.0 was a mistake, I should not have replaced pytz with zoneinfo, at least not in one go, a slower deprecation would have been better. Or maybe a fork. I lost track of why this library exist in the first place, I’m sorry about that.

Why tzlocal exists

tzlocal exists because there was no way to get the local timezone with pytz. In dateutil, you could, it had a method for that, with pytz, you HAD to know the local timezone name. So I made this library to get the local timezone name. However, I realized that some Unix installations did not have a local timezone configured, instead you had to use the /etc/localtime file. In that case, you couldn’t figure out the name, you could only return the anonymous timezone.

So, tzlocal returned pytz timezone objects, to deal with that.

The mess

Then came zoneinfo, and @agronholm needed a zoneinfo version of tzlocal. And I thought “Well, people are going to stop using pytz over time, so…”

However… on Unix (haven’t tried OS X yet) you can do zoneinfo.ZoneInfo(‘localtime’). So you don’t actually need tzlocal at all. And on Windows you can always find a zoneinfo name, so you don’t need tzlocal to return an object, just the zoneinfo name.

So switching tzlocal to return ZoneInfo objects actually never made sense. But that’s what happened. So the question now, is how to get out of the mess. And there are a few ways:

Option 1

  • Release a 4.0 that deprecates the get_localzone() functions for get_localzone_name() functions (I did that and released it as 4.0b2), and move tzlocal to only look for a name.
  • Support pytz users by releasing a pytz version (maybe without the deprecation) as 2.2.
  • Drawback: 2.x is Python 2 compatible otherwise, so people on python 2 may have pinned tzlocal < 3, so not ideal.

Option 2

  • Yank 3.x and 4.x, so people don’t install them by mistake
  • Return tzlocal to pytz support and release it as 5.0 with the get_localzone_name() function for zoneinfo use. This would mean installing pytz even though you don’t need it.
  • Drawback: People who switched to zoneinfo and didn’t pin the version will get breakage.

Option 3

  • Yank 3.x and 4.x, and return tzlocal to pytz support, and release it as 2.2.
  • Make a new library called , maybe, tzlocalname that returns the name of the local timezone.
  • Drawback: People who switched to zoneinfo and didn’t pin the version will get breakage.

Option 4

  • Release a 4.0 that deprecates the get_localzone() functions for get_localzone_name() functions (I did that and released it as 4.0b2), and move tzlocal to only look for a name, with removing the zoneinfo support in 5.0.
  • Release a pytz version called pytzlocal
  • Drawback: None that 3.0 didn’t already create.

Option 5

  • Deprecate tzlocal completely
  • Release tzlocalname to get the name
  • Release pytzlocal to get a pytz object
  • Drawback: None, I think?

Option 6

  • Your suggestions here.

Please discuss!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:27 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
regebrocommented, Oct 18, 2021

4.0 released, so time to close this. Thanks for the feedback!

2reactions
pgansslecommented, Oct 4, 2021

Also, should get_localzone_name() return None or error out if no name is found?

I would recommend error, since almost certainly the consumers of such an API will be counting on a non-None value there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pedestrian At Best - Courtney Barnett - YouTube
Put me on a pedestal and I'll only disappoint you. ... having an existential time crisis, what bliss, daylight savings won't fix this...
Read more >
"My Home is Always a Mess!" | 3 Steps to Break Out of a Rut
You will also get some very handy tips for how to keep your spirits ... With Me || Small Home Speed Clean 2020:...
Read more >
Parachute - The Mess I Made - YouTube
Music video by Parachute performing The Mess I Made. (C) 2009 The Island Def Jam Music Group.
Read more >
I'M STRUGGLING HARD! How to Fix Your Life When It's A Mess
What do you do when your life is a mess ? I share what's been going on for me + walk through 7...
Read more >
How to Repair a Textured Wall in 3 Different Ways - YouTube
Get FULL access to me and my team for Q and A's in the DIY Crew Forum ▻ Receive merch discounts dropping SOON!!!...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found