update pytz to 2023.2/2023b tzdata?

Brian Inglis Brian.Inglis@Shaw.ca
Mon Mar 27 00:13:31 GMT 2023


On 2023-03-26 14:45, Brian Inglis via Cygwin wrote:
> On 2023-03-07 22:11, Marco Atzeri wrote:
>> On 07.03.2023 22:35, marco atzeri wrote:
>>> On Tue, Mar 7, 2023 at 10:18 PM Brian Inglis wrote:
>>>> On 2022-03-20 10:00, Brian Inglis wrote:
>>>>> On 2021-12-21 09:06, Marco Atzeri wrote:
> 
>>>>>> python39-pytz                           2021.3-1
> 
>>>> Update needed to 2022g/2022.7.1 as a new Mexican zone was added since
>>>> 2021c/2021.3 due to Mexican changes conflicting with US practices, affecting
>>>> border towns:
> 
>> 2022.7.1 is up
> 
> Thanks Marco,
> 
> Looks like pytz needs another update as tzdata was updated twice this week!
> Some middle eastern governments just realized Ramadan was during DST ;^>
> 
> $ pytz-date.py "%Y %b %d %a %T %Z%z" Asia/Beirut
> 2023 Mar 26 Sun 20:41:45 UTC+0000       zoneinfo        UTC
> 2023 Mar 26 Sun 22:41:45 EET+0200       zoneinfo        Asia/Beirut
> 2023 Mar 26 Sun 23:41:45 EEST+0300      pytz            Asia/Beirut

I am unfamiliar with python and pytz, and I had a *local* pip install of pytz, 
which looks like it was overriding the Cygwin install.
After doing a local pip uninstall and Cygwin reinstall, with updated tzdata 
only, it appears that current pytz may now be giving the correct results:

$ ./pytz-date.py +"%Y %b %d %a %T %Z%z" Asia/Beirut
2023 Mar 27 Mon 00:05:57 UTC+0000       zoneinfo        UTC
2023 Mar 27 Mon 00:05:57 UTC+0000       pytz            UTC
2023 Mar 27 Mon 02:05:57 EET+0200       zoneinfo        Asia/Beirut
2023 Mar 27 Mon 02:05:57 EET+0200       pytz            Asia/Beirut

so an updated release may not be required?
There have been no zone changes, just DST rules.

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry
-------------- next part --------------
#!/usr/bin/python
# pytz-date.py - print current UTC, zoneinfo and pytz date time
#                in optional format "+"$1 in zone $#

from datetime import datetime
from zoneinfo import ZoneInfo
from pytz import timezone
import pytz
import sys
import os

TZ          = "TZ"                      # env var
GMT         = "GMT"                     # ref zones
GMTP0       = "GMT+0"
GMTM0       = "GMT-0"
UTC         = "UTC"
refs        = [ UTC , GMT , GMTP0 , GMTM0 ]
FMT         = "%c %Z%z"
zi_fmt      = "%tzoneinfo%t"
pytz_fmt    = "%tpytz%t%t"

dt_fmt      = FMT
tz          = os.getenv( TZ, UTC)       # TZ env var else UTC
argc        = len( sys.argv )
argn        = 1

# $1 +fmt optional override
if argc > argn and sys.argv[argn][0] == "+":
    dt_fmt  = sys.argv[argn][1:]
    argn   += 1

# $# zone
if argc > argn:
    tz  = sys.argv[argn]

# zone ref UTC
zones = [ UTC ]
# add arg if not same as ref
if tz not in refs:
    zones = zones + [ tz ]

# print ref and arg with zoneinfo and pytz
for z in zones:
# TZ=z  date    +"f" - zoneinfo
        print( datetime.now( ZoneInfo( z )).strftime( dt_fmt + zi_fmt + z ))
# TZ=z  date    +"f" - pytz
        print( datetime.now().astimezone( timezone( z )).strftime( dt_fmt + pytz_fmt + z ))



More information about the Cygwin mailing list