Skip to content

Negative duration issue #18181

@1-more

Description

@1-more

Technically speaking the negative duration is not the valid ISO 8601, but we need to print it anyway.
This code:

use std::time::duration::Duration;

fn main() {
    let a = Duration::days(1) + Duration::seconds(1);

    println!("#1. Should be -{0}, in fact {1}", a, -a);

    let b = Duration::nanoseconds(1);

    println!("#2. Should be -{0}, in fact {1}", b, -b);
}

Produces:

Should be -P1DT1S, in fact P-1DT-1S
Should be -PT0.000000001S, in fact PT-1.999999999S

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions