Skip to content

Commit

Permalink
Doc to time ambiguity
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitarOnGithub committed Aug 3, 2024
1 parent 38a75d0 commit dd21d61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions temporals/periods.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,6 @@ def __contains__(self, item):
Then you can check if the pto period is within your quarter period:
>>> pto in quarter
TODO: Docs on time comparison
For more in-depth comparisons and functionality, see:
overlaps_with
overlapped_by
Expand All @@ -703,7 +701,7 @@ def __contains__(self, item):
if self._time_repeats(item):
raise TimeAmbiguityError(f"The provided TimePeriod '{item}' exist within this DatetimePeriod "
f"('{self}') more than once. For more information on this error, "
f"see <link to doc>")
f"see https://github.com/dimitarOnGithub/temporals/wiki/Misc")
if self.duration.days == 1:
if item.start < self.start.time():
if item.end <= self.end.time():
Expand All @@ -726,7 +724,7 @@ def __contains__(self, item):
if self._time_repeats(item):
raise TimeAmbiguityError(f"The provided unit of time ('{item}') exist within this DatetimePeriod "
f"('{self}') more than once. For more information on this error, "
f"see <link to doc>")
f"see https://github.com/dimitarOnGithub/temporals/wiki/Misc")
if self.duration.days == 1:
return True
return self.start.time() <= item <= self.end.time()
Expand Down Expand Up @@ -766,7 +764,7 @@ def overlaps_with(self,
if self._time_repeats(other):
raise TimeAmbiguityError(f"The provided TimePeriod '{other}' exist within this DatetimePeriod "
f"('{self}') more than once. For more information on this error, "
f"see <link to doc>")
f"see https://github.com/dimitarOnGithub/temporals/wiki/Misc")
if self.start.date() < self.end.date():
# Day stretches overnight - the start time must be before the start of this period but also after the
# end of it
Expand Down Expand Up @@ -822,7 +820,7 @@ def overlapped_by(self,
if self._time_repeats(other):
raise TimeAmbiguityError(f"The provided TimePeriod '{other}' exist within this DatetimePeriod "
f"('{self}') more than once. For more information on this error, "
f"see <link to doc>")
f"see https://github.com/dimitarOnGithub/temporals/wiki/Misc")
if self.start.date() < self.end.date():
# Day stretches overnight - the start time must be after the start of this period but also after the
# end of it
Expand Down
4 changes: 2 additions & 2 deletions tests/test_datetimeperiod.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ def test_ambiguity_time(self):
""" 2 days long period
2024-01-01 0800 2024-01-02 1200
/==========================================================/
/=========/ /=========/
0700 1200 0700 1400
/=========/ /=========/
1000 1400 1000 1400
"""
self.start = datetime(2024, 1, 1, 8, 0)
self.end = datetime(2024, 1, 3, 12, 0)
Expand Down

0 comments on commit dd21d61

Please sign in to comment.