forked from Byron/cargo-smart-release
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix use of span to get number of days
This commit revises the change in Byron#28 to be a bit more robust. Originally, before Byron#28, the code was buggy because, I think, `Span` was being used like a normal "absolute" duration. But a `Span` keeps track of values for each individual unit. It isn't just a single number of nanoseconds like, e.g., `std::time::Duration` is. It's "smarter" than that. It deals with non-uniform units like days, months and years. But to do it correctly, you need a reference date. What this means is that when you get a `Span` by subtracting two `Zoned` values, you can't just ask the `Span` for the total number of days via `get_days()`. It has to be *computed*. In Byron#28, this was done for one case but not the other via the `Span::total` API. While this works today, the code was not providing a reference date, which means days are silently treated as always being 24 hours long. See BurntSushi/jiff#48 for more details where it's likely that this sort of usage will return an error in `jiff 0.2`. The main gotcha here is that since this is using `gix::date`, the `Zoned` values that are created are just "fixed offset" datetimes. They don't actually have a time zone. So in practice, such datetimes will always have all days be 24 hours long. This is not correct, but it's not clear to me that this is fixable inside the context of `git`. But at least with this patch, if you do ever end up using true time zones, then this code will be robust to that.
- Loading branch information
1 parent
44f2371
commit 9309196
Showing
3 changed files
with
31 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters