Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

Datetime rounds fractional seconds instead of truncating #186

Closed
alanhdu opened this issue Jun 1, 2017 · 0 comments
Closed

Datetime rounds fractional seconds instead of truncating #186

alanhdu opened this issue Jun 1, 2017 · 0 comments

Comments

@alanhdu
Copy link
Contributor

alanhdu commented Jun 1, 2017

According to the TOML spec:

The precision of fractional seconds is implementation specific, but at least millisecond precision is expected. If the value contains greater precision than the implementation can support, the additional precision must be truncated, not rounded.

Right now, toml seems to round fractional seconds instead. One fun consequence of this is that:

extern crate toml;
fn main() {
    let s = "n = 17:45:00.999999999999999999";
    let data: toml::Value = toml::from_str(s).unwrap();
    let s1 = toml::to_string(&data).unwrap();
    println!("{:?}", s1);
}

prints out 17:45:001, which isn't a valid time.

Found with https://github.com/rust-fuzz/targets

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant