diff options
Diffstat (limited to 'vendor/time/src/formatting/iso8601.rs')
-rw-r--r-- | vendor/time/src/formatting/iso8601.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/vendor/time/src/formatting/iso8601.rs b/vendor/time/src/formatting/iso8601.rs index 229a07ebc..29d443ef4 100644 --- a/vendor/time/src/formatting/iso8601.rs +++ b/vendor/time/src/formatting/iso8601.rs @@ -2,6 +2,7 @@ use std::io; +use crate::convert::*; use crate::format_description::well_known::iso8601::{ DateKind, EncodedConfig, OffsetPrecision, TimePrecision, }; @@ -84,17 +85,17 @@ pub(super) fn format_time<const CONFIG: EncodedConfig>( match Iso8601::<CONFIG>::TIME_PRECISION { TimePrecision::Hour { decimal_digits } => { let hours = (hours as f64) - + (minutes as f64) / 60. - + (seconds as f64) / 3_600. - + (nanoseconds as f64) / 3_600. / 1_000_000_000.; + + (minutes as f64) / Minute.per(Hour) as f64 + + (seconds as f64) / Second.per(Hour) as f64 + + (nanoseconds as f64) / Nanosecond.per(Hour) as f64; format_float(output, hours, 2, decimal_digits)?; } TimePrecision::Minute { decimal_digits } => { bytes += format_number_pad_zero::<2>(output, hours)?; bytes += write_if(output, Iso8601::<CONFIG>::USE_SEPARATORS, b":")?; let minutes = (minutes as f64) - + (seconds as f64) / 60. - + (nanoseconds as f64) / 60. / 1_000_000_000.; + + (seconds as f64) / Second.per(Minute) as f64 + + (nanoseconds as f64) / Nanosecond.per(Minute) as f64; bytes += format_float(output, minutes, 2, decimal_digits)?; } TimePrecision::Second { decimal_digits } => { @@ -102,7 +103,7 @@ pub(super) fn format_time<const CONFIG: EncodedConfig>( bytes += write_if(output, Iso8601::<CONFIG>::USE_SEPARATORS, b":")?; bytes += format_number_pad_zero::<2>(output, minutes)?; bytes += write_if(output, Iso8601::<CONFIG>::USE_SEPARATORS, b":")?; - let seconds = (seconds as f64) + (nanoseconds as f64) / 1_000_000_000.; + let seconds = (seconds as f64) + (nanoseconds as f64) / Nanosecond.per(Second) as f64; bytes += format_float(output, seconds, 2, decimal_digits)?; } } |