From 920cfa5f1bf704395a627fc61109bfe016e29cdd Mon Sep 17 00:00:00 2001 From: yuankunzhang Date: Thu, 14 Aug 2025 22:19:40 +0800 Subject: [PATCH] refactor: optimize time type sizes and add convertion from Time to jiff::civil::Time --- src/items/builder.rs | 6 +++--- src/items/time.rs | 43 +++++++++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/items/builder.rs b/src/items/builder.rs index 021fae8..ae241c1 100644 --- a/src/items/builder.rs +++ b/src/items/builder.rs @@ -223,9 +223,9 @@ impl DateTimeBuilder { dt.year(), dt.month(), dt.day(), - hour, - minute, - second, + hour as u32, + minute as u32, + second as u32, nanosecond, offset, )?; diff --git a/src/items/time.rs b/src/items/time.rs index 56328bf..5ece5c2 100644 --- a/src/items/time.rs +++ b/src/items/time.rs @@ -51,11 +51,25 @@ use super::{ #[derive(PartialEq, Clone, Debug, Default)] pub(crate) struct Time { - pub hour: u32, - pub minute: u32, - pub second: u32, - pub nanosecond: u32, - pub offset: Option, + pub(crate) hour: u8, + pub(crate) minute: u8, + pub(crate) second: u8, + pub(crate) nanosecond: u32, + pub(crate) offset: Option, +} + +impl TryFrom