@@ -606,6 +606,7 @@ fn test_rfc_2822_year_range_panic_low() {
606606
607607#[ test]
608608#[ cfg( feature = "alloc" ) ]
609+ #[ allow( deprecated) ]
609610fn test_datetime_rfc3339 ( ) {
610611 let edt5 = FixedOffset :: east_opt ( 5 * 60 * 60 ) . unwrap ( ) ;
611612 let edt0 = FixedOffset :: east_opt ( 0 ) . unwrap ( ) ;
@@ -691,6 +692,31 @@ fn test_datetime_rfc3339() {
691692 assert ! ( DateTime :: parse_from_rfc3339( " 2015-02-18T23:59:60.234567+05:00" ) . is_err( ) ) ;
692693 assert ! ( DateTime :: parse_from_rfc3339( "2015- 02-18T23:59:60.234567+05:00" ) . is_err( ) ) ;
693694 assert ! ( DateTime :: parse_from_rfc3339( "2015-02-18T23:59:60.234567A+05:00" ) . is_err( ) ) ;
695+
696+ const RFC_3339_YEAR_MAX : i32 = 9999 ;
697+ const RFC_3339_YEAR_MIN : i32 = 0 ;
698+
699+ let dt = Utc . with_ymd_and_hms ( RFC_3339_YEAR_MAX , 1 , 2 , 3 , 4 , 5 ) . unwrap ( ) ;
700+ assert_eq ! ( dt. to_rfc3339( ) , "9999-01-02T03:04:05+00:00" ) ;
701+
702+ let dt = Utc . with_ymd_and_hms ( RFC_3339_YEAR_MIN , 1 , 2 , 3 , 4 , 5 ) . unwrap ( ) ;
703+ assert_eq ! ( dt. to_rfc3339( ) , "0000-01-02T03:04:05+00:00" ) ;
704+ }
705+
706+ #[ test]
707+ #[ should_panic]
708+ #[ cfg( feature = "alloc" ) ]
709+ #[ allow( deprecated) ]
710+ fn test_rfc_3339_year_range_panic_high ( ) {
711+ let _ = Utc . with_ymd_and_hms ( 10000 , 1 , 2 , 3 , 4 , 5 ) . unwrap ( ) . to_rfc3339 ( ) ;
712+ }
713+
714+ #[ test]
715+ #[ should_panic]
716+ #[ cfg( feature = "alloc" ) ]
717+ #[ allow( deprecated) ]
718+ fn test_rfc_3339_year_range_panic_low ( ) {
719+ let _ = Utc . with_ymd_and_hms ( -1 , 1 , 2 , 3 , 4 , 5 ) . unwrap ( ) . to_rfc3339 ( ) ;
694720}
695721
696722#[ test]
0 commit comments