Closed chrisimcevoy closed 4 months ago
Attention: Patch coverage is 95.12195%
with 12 lines
in your changes missing coverage. Please review.
Project coverage is 95.54%. Comparing base (
d989c2b
) to head (cf5bf40
). Report is 27 commits behind head on main.
Files with missing lines | Patch % | Lines |
---|---|---|
pyoda_time/_duration.py | 40.00% | 6 Missing :warning: |
pyoda_time/text/_duration_pattern.py | 92.20% | 6 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Brief bit of exposition needed here first.
In .NET, spans of time tend to be represented by
TimeSpan
. The Noda Time equivalent to that is aDuration
. Noda Time'sDuration
is capable of conversion to and from all the values in the range ofTimeSpan
, which covers 292 years or so. In fact, Noda Time's Duration has a much larger range than that, something like 20,000+ years.When
Duration
was implemented back in #47, I decided that for Pyoda Time,Duration
should have a similar relationship withdatetime.timedelta
, i.e. it should be possible to convert all possibletimedelta
values to and from the Pyoda type. The thing is thattimedelta
's range is so vast that it makes the .NET range look measly by comparison.At the time, I decided to drastically increase the range of
Duration
from the range offered by Noda Time, so that the PyodaDuration
would have a range which is slightly larger thantimedelta
. That decision has had knock-on effects for theDurationPattern
port, particularly with regard to parsing validation and so forth.The end result is that this
DurationPattern
implementation is very reminiscent of the one you'll find in the mother project, but it allows for much, much greater values to be parsed and formatted.One other small note. I'm currently having a discussion with myself over in #154 about string formatting stuff. Included in this PR is the use of the new pattern in
Duration.__str__
andDuration.__format__
. There is no test coverage for that currently, but I had a bit of a play in a REPL and...