Skip to content

Commit

Permalink
Document Duration's Display format (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
quodlibetor authored Jan 22, 2021
1 parent 2b53360 commit 19ec092
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/oldtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ macro_rules! try_opt {
}

/// ISO 8601 time duration with nanosecond precision.
///
/// This also allows for the negative duration; see individual methods for details.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
pub struct Duration {
Expand Down Expand Up @@ -373,6 +374,9 @@ impl Div<i32> for Duration {
}

impl fmt::Display for Duration {
/// Format a duration using the [ISO 8601] format
///
/// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601#Durations
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// technically speaking, negative duration is not valid ISO 8601,
// but we need to print it anyway.
Expand Down

0 comments on commit 19ec092

Please sign in to comment.