/// Format the time portion of ISO 8601. #[inline] pub(super) fn format_time<V, const CONFIG: EncodedConfig>(
output: &mut (impl io::Write + ?Sized),
value: &V,
state: &mut V::State,
) -> Result<usize, error::Format> where
V: ComponentProvider,
{ 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",
)?;
match Iso8601::<CONFIG>::TIME_PRECISION {
TimePrecision::Hour { decimal_digits } => { let hours = (value.hour(state) as f64)
+ (value.minute(state) as f64) / Minute::per_t::<f64>(Hour)
+ (value.second(state) as f64) / Second::per_t::<f64>(Hour)
+ (value.nanosecond(state) as f64) / Nanosecond::per_t::<f64>(Hour);
format_float(output, hours, 2, decimal_digits)?;
}
TimePrecision::Minute { decimal_digits } => {
bytes += format_number_pad_zero::<2>(output, value.hour(state))?;
bytes += write_if(output, Iso8601::<CONFIG>::USE_SEPARATORS, b":")?; let minutes = (value.minute(state) as f64)
+ (value.second(state) as f64) / Second::per_t::<f64>(Minute)
+ (value.nanosecond(state) as f64) / Nanosecond::per_t::<f64>(Minute);
bytes += format_float(output, minutes, 2, decimal_digits)?;
}
TimePrecision::Second { decimal_digits } => {
bytes += format_number_pad_zero::<2>(output, value.hour(state))?;
bytes += write_if(output, Iso8601::<CONFIG>::USE_SEPARATORS, b":")?;
bytes += format_number_pad_zero::<2>(output, value.minute(state))?;
bytes += write_if(output, Iso8601::<CONFIG>::USE_SEPARATORS, b":")?; let seconds = (value.second(state) as f64)
+ (value.nanosecond(state) as f64) / Nanosecond::per_t::<f64>(Second);
bytes += format_float(output, seconds, 2, decimal_digits)?;
}
}
Ok(bytes)
}
/// Format the UTC offset portion of ISO 8601. #[inline] pub(super) fn format_offset<V, const CONFIG: EncodedConfig>(
output: &mut (impl io::Write + ?Sized),
value: &V,
state: &mut V::State,
) -> Result<usize, error::Format> where
V: ComponentProvider,
{ if Iso8601::<CONFIG>::FORMAT_TIME && value.offset_is_utc(state) { 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.