-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: add options for controlling precision
This PR introduces new options for controlling the precision of fractional seconds when printing `Zoned`, `Timestamp`, `civil::DateTime` or `civil::Time` values. This is principally exposed via `jiff::fmt::temporal::DateTimePrinter::precision`, but it's also available via the standard library's formatting machinery. For example, if `zdt` is a `jiff::Zoned`, then `format!("{zdt:.6}")` will format it into a string with microsecond precision, even if its fractional component is zero. This is useful when one wants a datetime to use a "fixed width" format. Or at least, as close to one as possible. For `Zoned` in particular, a fixed width format is somewhat difficult to accomplish because of the variable length IANA time zone identifier. But if the time zone identifier is the same for all `Zoned` values in a particular context, then setting the precision will provide fixed width. (Unless the years are negative.) Closes #92
- Loading branch information
1 parent
8839f9c
commit 626bba1
Showing
7 changed files
with
348 additions
and
10 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
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
Oops, something went wrong.