Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency between truncated dates and truncated times #212

Open
MetRonnie opened this issue Apr 20, 2022 · 0 comments · May be fixed by #234
Open

Inconsistency between truncated dates and truncated times #212

MetRonnie opened this issue Apr 20, 2022 · 0 comments · May be fixed by #234
Labels
Milestone

Comments

@MetRonnie
Copy link
Contributor

MetRonnie commented Apr 20, 2022

When adding a truncated TimePoint to a regular TimePoint, if the truncated one specifies a date, all units smaller than the ones provided are not taken into account, whereas if it specifies a time, the smaller units are implicitly zero.

>>> parser = TimePointParser(allow_truncated=True)
>>> regular = parser.parse("2010-08-08T15:40:13Z")
>>> truncated_date = parser.parse("--10")  # month = 10 (October)
>>> regular + truncated_date
<metomi.isodatetime.data.TimePoint: 2010-10-08T15:40:13Z>

Note how the day of month and time from the regular TimePoint are retained

>>> truncated_time = parser.parse("T19")
>>> regular + truncated_time
<metomi.isodatetime.data.TimePoint: 2010-08-08T19:00:00Z>

Note how the minutes and seconds have gone to zero, as if they were taken from the truncated TimePoint which is assumed to be equivalent to T19:00:00.

To me, it seems debatable which is the correct approach for addition of regular and truncated TimePoints, but at least the approach should be consistent.

@MetRonnie MetRonnie added this to the 4.0.0 milestone Apr 20, 2022
@oliver-sanders oliver-sanders modified the milestones: 4.0.0, 3.2.0 May 17, 2022
@MetRonnie MetRonnie linked a pull request Jan 15, 2024 that will close this issue
2 tasks
@MetRonnie MetRonnie added bug and removed question labels Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants