Closed bxparks closed 3 months ago
Note that the current release, disambiguate
doesn't affect gaps (they always raise an exception).
release 0.4 (see the PR) also adds support for gaps, in which case "earlier" and "later" behave as you'd expect. i.e. earlier is fold=0 for ambiguity, and fold=1 for gaps.
In any case, have a look at what I'm working on for 0.4, which also affects LocalDateTime
. Start with the CHANGELOG.rst
to see what has changed.
I'll see if I can get the release candidate docs built on readthedocs.org 👀
@bxparks you can find the 0.4 release (candidate) docs here: https://whenever.readthedocs.io/en/0.4-dev/
The behavior is now fixed and documented.
https://whenever.readthedocs.io/en/latest/api.html#whenever.ZonedDateTime
The
ZonedDateTime
takes an optionaldisambiguate
parameter which allows"later"
and"earlier"
. I think the documentation may need to be more explicit about the behavior is during a "gap". If the library converts the"earlier"
string tofold=0
(as documented in the API docs), then according to PEP 495, theZonedDateTime
will actually pick the later datetime, which contradicts the documentation. Similarly, if"later"
is chosen and it setsfold=1
, then during a gap, the earlier datetime will be selected.Secondly, I think the API documentation should probably contain a reference to PEP 495 somewhere around the first mention of the
fold
parameter, because it's basically impossible to understand what that parameter means without PEP 495.Thirdly, it looks like the
fold
parameter is no longer exposed throughLocalDateTime
, but the API documentation still has some examples with an explicitfold=0
orfold=1
in the constructor ofLocalDateTime
. (I don't want to create too many tickets, so I included this minor issue here.)