Page MenuHomePhabricator

Incorrect default month and day for WbTime
Closed, ResolvedPublicBUG REPORT

Description

Per the definition in mw:Wikibase/DataModel the default values for month and day should be 00 and not 01.

As I noted in T107870 this will however break naive date comparisons. As such we might want to do more than just change WbTime.__init__.py.

Related Objects

Event Timeline

Lokal_Profil raised the priority of this task from to Needs Triage.
Lokal_Profil updated the task description. (Show Details)
Lokal_Profil subscribed.
thiemowmde triaged this task as Lowest priority.Dec 6 2017, 11:20 PM
thiemowmde subscribed.

The default really does not matter. It's actually entirely meaningless. We are using 00 for the month and the day to make it more obvious that there is no month and no day, and they should not be used for anything.

For example, if the precision is set to "month", the values 2017-04-00 and 2017-04-01 and even 2017-04-25 are all the same and should all return true in a comparison.

For example, if the precision is set to "month", the values 2017-04-00 and 2017-04-01 and even 2017-04-25 are all the same and should all return true in a comparison.

In terms of OOP this is a bad idea because the values are not actually the same. Maybe this can be dealt with by adding a new method "relative_time_equal" which does factor in precision when checking for equality.

the values are not actually the same.

They are not identical, but equal for all practical purposes. It's possible to have both concepts next to each other in the same codebase. As you suggested it's a good idea to make the distinction visible via well-chosen method names, or to add a normalization step that makes them identical.

Would approximately_equal be a good method name?

Actually I think normalization would help solve the problem. The fix then is simple.

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

[pywikibot/core@master] [Feature] Allow normalization of WbTime objects

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

RPI2026F1 changed the task status from Open to In Progress.Dec 14 2022, 9:28 PM
RPI2026F1 claimed this task.
RPI2026F1 raised the priority of this task from Lowest to Low.
RPI2026F1 changed the subtype of this task from "Task" to "Bug Report".
RPI2026F1 changed the status of subtask T148280: WbTime comparison is incorrect from Open to In Progress.

Change 868173 merged by jenkins-bot:

[pywikibot/core@master] [Feature] Allow normalization of WbTime objects

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