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.
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.
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
[Feature] Allow normalization of WbTime objects | pywikibot/core | master | +180 -0 |
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.
Change 868173 had a related patch set uploaded (by RPI2026F1; author: RPI2026F1):
[pywikibot/core@master] [Feature] Allow normalization of WbTime objects
Change 868173 merged by jenkins-bot:
[pywikibot/core@master] [Feature] Allow normalization of WbTime objects