diff --git a/src/logging.rs b/src/logging.rs index 0917a2b..e1f26a7 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -525,7 +525,15 @@ fn spawn_logline(commands: &mut Commands, parent: Entity, event: &LogEvent) -> E TextSpan::new( event .timestamp - .format(&iso8601::Iso8601::<{ iso8601_with_two_digit_secs() }> {}) + .format(&iso8601::Iso8601::< + { + iso8601::Config::DEFAULT + .set_time_precision(iso8601::TimePrecision::Second { + decimal_digits: Some(NonZero::new(2).unwrap()), + }) + .encode() + }, + > {}) .unwrap_or("timestamp error".to_string()), ), TextFont::from_font_size(LOG_LINE_FONT_SIZE), @@ -586,18 +594,3 @@ fn on_level_filter_chip( } } } - -/// ISO 8601 Config with two decimal digits for seconds. -const fn iso8601_with_two_digit_secs() -> u128 { - // This is a hack to get around .unwrap() not being stable as a const fn - const TWO: NonZero = match NonZero::new(2) { - Some(two) => two, - None => unreachable!(), - }; - - iso8601::Config::DEFAULT - .set_time_precision(iso8601::TimePrecision::Second { - decimal_digits: Some(TWO), - }) - .encode() -}