@@ -100,3 +100,61 @@ impl TryFrom<OffsetDateTime> for Time {
100100 Self :: new ( params) . map_err ( |e| ConversionError ( ConversionErrorInner :: InvalidUefiTime ( e) ) )
101101 }
102102}
103+
104+ #[ cfg( test) ]
105+ mod tests {
106+ use super :: super :: integration_common:: test_helpers;
107+ use super :: * ;
108+ use time:: { OffsetDateTime , PrimitiveDateTime } ;
109+
110+ #[ test]
111+ fn primitive_roundtrip_basic ( ) {
112+ test_helpers:: primitive_roundtrip :: < PrimitiveDateTime > ( ) ;
113+ }
114+
115+ #[ test]
116+ fn zoned_roundtrip_positive_offset ( ) {
117+ test_helpers:: zoned_roundtrip :: < OffsetDateTime > ( ) ;
118+ }
119+
120+ #[ test]
121+ fn zoned_roundtrip_negative_offset ( ) {
122+ test_helpers:: negative_offset_roundtrip :: < OffsetDateTime > ( ) ;
123+ }
124+
125+ #[ test]
126+ fn nanoseconds_preserved ( ) {
127+ test_helpers:: preserves_nanoseconds :: < OffsetDateTime > ( ) ;
128+ }
129+
130+ #[ test]
131+ fn unspecified_timezone_is_rejected ( ) {
132+ test_helpers:: unspecified_timezone_fails :: < OffsetDateTime > ( ) ;
133+ }
134+
135+ #[ test]
136+ fn invalid_date_is_rejected ( ) {
137+ test_helpers:: invalid_calendar_date_fails :: < PrimitiveDateTime > ( ) ;
138+ }
139+
140+ // important real-world offset edge case
141+ #[ test]
142+ fn half_hour_timezone_roundtrip ( ) {
143+ let t = test_helpers:: sample_time ( 90 ) ; // +01:30
144+
145+ let dt: OffsetDateTime = t. try_into ( ) . unwrap ( ) ;
146+ let back: Time = dt. try_into ( ) . unwrap ( ) ;
147+
148+ assert_eq ! ( back. 0 . time_zone, 90 ) ;
149+ }
150+
151+ #[ test]
152+ fn negative_half_hour_timezone_roundtrip ( ) {
153+ let t = test_helpers:: sample_time ( -330 ) ; // -05:30
154+
155+ let dt: OffsetDateTime = t. try_into ( ) . unwrap ( ) ;
156+ let back: Time = dt. try_into ( ) . unwrap ( ) ;
157+
158+ assert_eq ! ( back. 0 . time_zone, -330 ) ;
159+ }
160+ }
0 commit comments