Page MenuHomePhabricator

pywikibot.WbTime does not correctly apply timezone information during comparisons
Closed, ResolvedPublicBUG REPORT

Description

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

ts1 = pywikibot.Timestamp(
    year=2022, month=12, day=21, hour=13,
    tzinfo=datetime.timezone(datetime.timedelta(hours=-5)))
ts2 = pywikibot.Timestamp(
    year=2022, month=12, day=21, hour=17,
    tzinfo=datetime.timezone.utc)
ts1.timestamp() > ts2.timestamp() # True

t1 = pywikibot.WbTime.fromTimestamp(ts1, timezone=-300)
t2 = pywikibot.WbTime.fromTimestamp(ts2, timezone=0)
t1 > t2 # False?

What happens?: Timestamps that should be greater than are not.

What should have happened instead?: They should be greater than.

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

Other information (browser name/version, screenshots, etc.): When I made the comparison operators, I accidentally applied the timezone shift backwards.

Event Timeline

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

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

[pywikibot/core@master] [Bugfix] Correctly adjust for timezones during comparisons

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

Change 871015 merged by jenkins-bot:

[pywikibot/core@master] [Bugfix] Correctly adjust for timezones during comparisons

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