Page MenuHomePhabricator

pywikibot.WbTime.fromTimestamp discards timezone information
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

import zoneinfo # This is the stdlib version of pytz, only available in python 3.9+
x = pywikibot.Timestamp(year=2022, month=12, day=21, hour=12, tzinfo=zoneinfo.ZoneInfo("America/New_York"))
y = pywikibot.Timestamp(year=2022, month=12, day=21, hour=17, tzinfo=zoneinfo.ZoneInfo("UTC"))
xt = pywikibot.WbTime.fromTimestamp(x)
yt = pywikibot.WbTime.fromTimestamp(y)
print(x.timestamp() == y.timestamp()) # Should be true
print(xt._getSecondsAdjusted() == yt._getSecondsAdjusted()) # Should be true

What happens?: First line is true and second line is false since all timestamps are treated like they are in the same timezone even if the timestamp has a tzinfo property.

What should have happened instead?: Both lines should be true.

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

RPI2026F1 changed the task status from Open to In Progress.Dec 23 2022, 2:44 AM
RPI2026F1 claimed this task.
RPI2026F1 triaged this task as Medium priority.
RPI2026F1 changed the task status from In Progress to Stalled.Dec 23 2022, 3:01 AM

Change 878200 had a related patch set uploaded (by RPI2026F1; author: RPI2026F1):

[pywikibot/core@master] [Feature] Allow copying timezone from Timestamp

https://gerrit.wikimedia.org/r/878200

RPI2026F1 changed the task status from Stalled to In Progress.Jan 10 2023, 9:52 PM
RPI2026F1 lowered the priority of this task from Medium to Low.

Change 878200 merged by jenkins-bot:

[pywikibot/core@master] [Feature] Allow copying timezone from Timestamp

https://gerrit.wikimedia.org/r/878200