-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fmt/strtime: support parsing and formatting fractional seconds
This isn't supported in the analogous C APIs, but it turns out it was supported in the `chrono` crate and was actually being used. This adds two new directives, `%f` and `%.f`. The former always writes out at least one digit (and parsing requires at least one digit) and corresponds to the number of fractional nanoseconds. The latter includes the leading `.` and is satisfied by the empty string. That is, if a `.` isn't found when `%.f` is expected, then it is skipped entirely when parsing. Similarly, when formatting, if there are no fractional seconds (i.e., the subsecond component is `0`), then no fractional component is written either. It is expected that most use cases will reach for just `%.f`, since it will just do the "right" thing without thinking much about it. For example, `%H:%M:%S%.f` will parse both `23:30:01` and `23:30:01.789`. Closes #54
- Loading branch information
1 parent
70c6ca0
commit 77dc509
Showing
6 changed files
with
396 additions
and
19 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
Oops, something went wrong.