Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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...