regebro / tzlocal

A Python module that tries to figure out what your local timezone is

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please allow timezone in the form CET-1

mowgli opened this issue · comments

My timezone (CET-1) is not able to express as Continent/City. It would be only true in the time between End of October and End of March.

There is no timezone that supports them anytime.

Even more, if I set Etc/CET it does use DST even if not expressed.

Where are you located?

CET has DST, yes. CET-1 would be the same as British time, so Europe/London should work in that case.

Well, CET-1 in TZ environment means that CET is just a label and -1 means that you have to subtract 1 hour to get UTC.

And no, CET has NO DTS. The DST for that is CEST. CET is always one hour more than UTC, always.

I don't use Summertime for years now for health reasons. I am one of the ~10% who have massive troubles with summertime!

We all have problems with summertime, but in your case you want GMT/UTC and using that as a timezone name works just fine. I don't know why you would need to express it as CET-1, but that's not a time zone recognized in the zoneinfo database, so there isn't anything I can do to help with that.

And CET does have daylight saving.

>>> import zoneinfo
>>> import datetime
>>> zoneinfo.ZoneInfo("CET").utcoffset(datetime.datetime(2022, 1, 1))
datetime.timedelta(seconds=3600)
>>> zoneinfo.ZoneInfo("CET").utcoffset(datetime.datetime(2022, 6, 1))
datetime.timedelta(seconds=7200)

So CET-1, if it worked, would could you daylight savings time.

The purpose of tzlocal is to figure out the timezone, primarily the zoneinfo name, used in the configuration of your computer. You are defining your own timezone that does not exist in the zoneinfo database. That means tzlocal fails.

I guess it's possible to parse the POSIX definition and create tzinfo objects from that. If someone wants to contribute that functionality I would accept that. However, as I have never seen, nor can I imagine, any use case where this would be necessary or desireable, I'm not going to implement it myself.

Also, notably, the attempt of finding the timezone name would still fail, as the ZoneInfo objects would not support this.

Since the timezone you are configuring is the exact same one as UTC, you can simply solve this by using UTC, making this a non-issue.

In ZoneInfo parlance that's Etc/GMT+1.