jiff: Inconsistency: Are days 24 hours or not?
There seems to be some inconsistency in the treatment of days in spans. In particular, TryFrom<Span> for Duration assumes that days are 24 hours, whereas Timestamp::saturating_add rejects days as units that can’t be resolved without a specific timezone.
Personaly I think the assumption that days are 24 hours is dangerous and shouldn’t be made (because it is readily violated by DST), but more than that I think all functions should at least agree on whether days are assumed to always be 24 hours or not.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 19 (9 by maintainers)
Commits related to this issue
- fix use of span to get number of days This commit revises the change in #28 to be a bit more robust. Originally, before #28, the code was buggy because, I think, `Span` was being used like a normal ... — committed to BurntSushi/cargo-smart-release by BurntSushi 2 years ago
- fix use of span to get number of days This commit revises the change in #28 to be a bit more robust. Originally, before #28, the code was buggy because, I think, `Span` was being used like a normal ... — committed to BurntSushi/cargo-smart-release by BurntSushi 2 years ago
- span: deprecate silent "days are 24 hours" in some cases This does make _some_ use cases a bit more annoying, but I think it overall makes the API more consistent. Essentially, unless `SpanRelativeTo... — committed to BurntSushi/jiff by BurntSushi 2 years ago
- span: deprecate silent "days are 24 hours" in some cases This does make _some_ use cases a bit more annoying, but I think it overall makes the API more consistent. Essentially, unless `SpanRelativeTo... — committed to BurntSushi/jiff by BurntSushi 2 years ago
- span: deprecate silent "days are 24 hours" in some cases This does make _some_ use cases a bit more annoying, but I think it overall makes the API more consistent. Essentially, unless `SpanRelativeTo... — committed to BurntSushi/jiff by BurntSushi 2 years ago
- span: require explicit opt-in for invariant 24-hour days This makes the `Span` APIs more consistent with the rest of Jiff in that days are never silently assumed to be 24 hours. Instead, callers are ... — committed to BurntSushi/jiff by BurntSushi 2 years ago
- span: require explicit opt-in for invariant 24-hour days This makes the `Span` APIs more consistent with the rest of Jiff in that days are never silently assumed to be 24 hours. Instead, callers are ... — committed to BurntSushi/jiff by BurntSushi 2 years ago
- span: require explicit opt-in for invariant 24-hour days This makes the `Span` APIs more consistent with the rest of Jiff in that days are never silently assumed to be 24 hours. Instead, callers are ... — committed to BurntSushi/jiff by BurntSushi 2 years ago
- span: require explicit opt-in for invariant 24-hour days This makes the `Span` APIs more consistent with the rest of Jiff in that days are never silently assumed to be 24 hours. Instead, callers are ... — committed to BurntSushi/jiff by BurntSushi 2 years ago
- span: require explicit opt-in for invariant 24-hour days This makes the `Span` APIs more consistent with the rest of Jiff in that days are never silently assumed to be 24 hours. Instead, callers are ... — committed to Mu-L/jiff by BurntSushi 2 years ago
That is definitely an issue that I could see happening, though my specific situation was a little different.
Basically I am parsing and processing some data dumps from some event logs. The documentation on the data format is limited, so I want to validate everything as strictly as possible. As part of that I want to enforce that there must be no ambiguity about the duration of spans. If there ever was ambiguity (e.g. if the event logs contained a span with days) then I would have to figure out what that actually means. The zoned datetimes only come into play because I later summarize the data in my local timezone (which has DST).
Not quite. If there is ambiguity about the duration of the spans then something is wrong with the input data and I will need to dig deeper into what that means. I am assuming that the durations will never contain ambiguous units like days or months, but I don’t know for sure, so my goal with rounding without providing a zoned datetime was to enforce that if my assumption turns out to be wrong I will get an error.