/// Format the time portion of ISO 8601. pub(super) fn format_time<const CONFIG: EncodedConfig>(
output: &mutimpl io::Write,
time: Time,
) -> Result<usize, error::Format> { letmut bytes = 0;
// The "T" can only be omitted in extended format where there is no date being formatted.
bytes += write_if(
output,
Iso8601::<CONFIG>::USE_SEPARATORS || Iso8601::<CONFIG>::FORMAT_DATE,
b"T",
)?;
let (hours, minutes, seconds, nanoseconds) = time.as_hms_nano();
match Iso8601::<CONFIG>::TIME_PRECISION {
TimePrecision::Hour { decimal_digits } => { let hours = (hours as f64)
+ (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) / 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 } => {
bytes += format_number_pad_zero::<2>(output, hours)?;
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) / Nanosecond::per(Second) as f64;
bytes += format_float(output, seconds, 2, decimal_digits)?;
}
}
Ok(bytes)
}
/// Format the UTC offset portion of ISO 8601. pub(super) fn format_offset<const CONFIG: EncodedConfig>(
output: &mutimpl io::Write,
offset: UtcOffset,
) -> Result<usize, error::Format> { if Iso8601::<CONFIG>::FORMAT_TIME && offset.is_utc() { return Ok(write(output, b"Z")?);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.