@@ -212,6 +212,7 @@ mod tests {
212212
213213 #[ cfg( test) ]
214214 mod offsets {
215+ use chrono:: FixedOffset ;
215216 use chrono:: { Local , NaiveDate } ;
216217
217218 use crate :: parse_datetime;
@@ -258,12 +259,25 @@ mod tests {
258259
259260 #[ test]
260261 fn test_datetime_with_offset ( ) {
261- let actual = parse_datetime ( "1997-01-19 08:17:48 +0 " ) . unwrap ( ) ;
262+ let actual = parse_datetime ( "1997-01-19 08:17:48 +2 " ) . unwrap ( ) ;
262263 let expected = NaiveDate :: from_ymd_opt ( 1997 , 1 , 19 )
263264 . unwrap ( )
264265 . and_hms_opt ( 8 , 17 , 48 )
265266 . unwrap ( )
266- . and_utc ( ) ;
267+ . and_local_timezone ( FixedOffset :: east_opt ( 2 * 3600 ) . unwrap ( ) )
268+ . unwrap ( ) ;
269+ assert_eq ! ( actual, expected) ;
270+ }
271+
272+ #[ test]
273+ fn test_datetime_with_timezone ( ) {
274+ let actual = parse_datetime ( "1997-01-19 08:17:48 BRT" ) . unwrap ( ) ;
275+ let expected = NaiveDate :: from_ymd_opt ( 1997 , 1 , 19 )
276+ . unwrap ( )
277+ . and_hms_opt ( 8 , 17 , 48 )
278+ . unwrap ( )
279+ . and_local_timezone ( FixedOffset :: west_opt ( 3 * 3600 ) . unwrap ( ) )
280+ . unwrap ( ) ;
267281 assert_eq ! ( actual, expected) ;
268282 }
269283 }
@@ -652,7 +666,7 @@ mod tests {
652666 assert_eq ! (
653667 parse_datetime( "28 feb 2023 + 1 day" )
654668 . unwrap( )
655- . format( "%+ " )
669+ . format( "%Y-%m-%dT%H:%M:%S%:z " )
656670 . to_string( ) ,
657671 "2023-03-01T00:00:00+00:00"
658672 ) ;
@@ -664,15 +678,15 @@ mod tests {
664678 assert_eq ! (
665679 parse_datetime( "2024-01-31 + 1 month" )
666680 . unwrap( )
667- . format( "%+ " )
681+ . format( "%Y-%m-%dT%H:%M:%S%:z " )
668682 . to_string( ) ,
669683 "2024-03-02T00:00:00+00:00" ,
670684 ) ;
671685
672686 assert_eq ! (
673687 parse_datetime( "2024-02-29 + 1 month" )
674688 . unwrap( )
675- . format( "%+ " )
689+ . format( "%Y-%m-%dT%H:%M:%S%:z " )
676690 . to_string( ) ,
677691 "2024-03-29T00:00:00+00:00" ,
678692 ) ;
0 commit comments