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

Cannot subtract truncated TimePoint from regular TimePoint #211

Open
MetRonnie opened this issue Apr 20, 2022 · 0 comments
Open

Cannot subtract truncated TimePoint from regular TimePoint #211

MetRonnie opened this issue Apr 20, 2022 · 0 comments
Milestone

Comments

@MetRonnie
Copy link
Contributor

MetRonnie commented Apr 20, 2022

It is possible to add a truncated TimePoint to a regular one (although that has a bug: #80). However, when trying to subtract a truncated TimePoint from a regular one:

File ~/metomi/isodatetime/data.py:1700, in TimePoint.__sub__(self, other)
   1698 def __sub__(self, other):
   1699     if isinstance(other, TimePoint):
-> 1700         if other > self:

File ~/metomi/isodatetime/data.py:1693, in TimePoint.__gt__(self, other)
   1692 def __gt__(self, other: "TimePoint") -> bool:
-> 1693     return self._cmp(other, "gt")

File ~/metomi/isodatetime/data.py:1659, in TimePoint._cmp(self, other, op)
   1657     return NotImplemented
   1658 if self._truncated != other._truncated:
-> 1659     raise ValueError(
   1660         "Cannot compare truncated to non-truncated "
   1661         "TimePoint: {0}, {1}".format(self, other))

ValueError: Cannot compare truncated to non-truncated TimePoint: -17T1200Z, 2022-04-20T11:12:00+01:00

But it should be possible to do this. Cylc has its own implementation: https://github.com/cylc/cylc-flow/blob/5361c428d7e4ad9faa6152cdf2c59f259077fbee/cylc/flow/cycling/iso8601.py#L747

@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 modified the milestones: 3.2.0, 3.x Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants