rocky / python-uncompyle6

A cross-version Python bytecode decompiler
GNU General Public License v3.0
3.74k stars 408 forks source link

pytz.timezone('Asia/Shanghai') has a bug! #457

Closed mikezang closed 1 year ago

mikezang commented 1 year ago

Please delete it, I made mistake!

Description

The pytz.timezone('Asia/Shanghai') is not correct with a bug!

How to Reproduce

You will find the bug If you run this code! The pytz.timezone('Asia/Shanghai') should be +8:00 in time zone, but it return +8:06!

from datetime import datetime, timedelta import pytz chinaTime = datetime(2023, 5, 27, tzinfo=pytz.timezone('Asia/Shanghai')) print(f'China time: {chinaTime}') utcTime = chinaTime.astimezone(pytz.UTC) print(f' UTC time: {utcTime}')`

Output Given

China time: 2023-05-27 00:00:00+08:06 -> this should be 2023-05-27 00:00:00+08:00 UTC time: 2023-05-26 15:54:00+00:00 -> and this should be 2023-05-26 16:00:00+00:00

Expected behavior

China time: 2023-05-27 00:00:00+08:00 UTC time: 2023-05-26 16:00:00+00:00

Environment

No any special setup, just install pyhton and install need packages

Workarounds

Priority

That will be error for all datetime calculation for China Time zone!

Additional Context