@@ -645,12 +645,12 @@ fn test_datetime_rfc2822() {
645
645
646
646
// timezone 0
647
647
assert_eq ! (
648
- Utc . with_ymd_and_hms( 2015 , 2 , 18 , 23 , 16 , 9 ) . unwrap( ) . to_rfc2822 ( ) ,
649
- "Wed, 18 Feb 2015 23:16:09 +0000"
648
+ Utc . with_ymd_and_hms( 2015 , 2 , 18 , 23 , 16 , 9 ) . unwrap( ) . try_to_rfc2822 ( ) . as_deref ( ) ,
649
+ Some ( "Wed, 18 Feb 2015 23:16:09 +0000" )
650
650
) ;
651
651
assert_eq ! (
652
- Utc . with_ymd_and_hms( 2015 , 2 , 1 , 23 , 16 , 9 ) . unwrap( ) . to_rfc2822 ( ) ,
653
- "Sun, 1 Feb 2015 23:16:09 +0000"
652
+ Utc . with_ymd_and_hms( 2015 , 2 , 1 , 23 , 16 , 9 ) . unwrap( ) . try_to_rfc2822 ( ) . as_deref ( ) ,
653
+ Some ( "Sun, 1 Feb 2015 23:16:09 +0000" )
654
654
) ;
655
655
// timezone +05
656
656
assert_eq ! (
@@ -661,8 +661,9 @@ fn test_datetime_rfc2822() {
661
661
. unwrap( )
662
662
)
663
663
. unwrap( )
664
- . to_rfc2822( ) ,
665
- "Wed, 18 Feb 2015 23:16:09 +0500"
664
+ . try_to_rfc2822( )
665
+ . as_deref( ) ,
666
+ Some ( "Wed, 18 Feb 2015 23:16:09 +0500" )
666
667
) ;
667
668
assert_eq ! (
668
669
DateTime :: parse_from_rfc2822( "Wed, 18 Feb 2015 23:59:60 +0500" ) ,
@@ -696,8 +697,9 @@ fn test_datetime_rfc2822() {
696
697
. unwrap( )
697
698
)
698
699
. unwrap( )
699
- . to_rfc2822( ) ,
700
- "Wed, 18 Feb 2015 23:59:60 +0500"
700
+ . try_to_rfc2822( )
701
+ . as_deref( ) ,
702
+ Some ( "Wed, 18 Feb 2015 23:59:60 +0500" )
701
703
) ;
702
704
703
705
assert_eq ! (
@@ -709,8 +711,8 @@ fn test_datetime_rfc2822() {
709
711
Ok ( FixedOffset :: east_opt( 0 ) . unwrap( ) . with_ymd_and_hms( 2015 , 2 , 18 , 23 , 16 , 9 ) . unwrap( ) )
710
712
) ;
711
713
assert_eq ! (
712
- ymdhms_micro( & edt, 2015 , 2 , 18 , 23 , 59 , 59 , 1_234_567 ) . to_rfc2822 ( ) ,
713
- "Wed, 18 Feb 2015 23:59:60 +0500"
714
+ ymdhms_micro( & edt, 2015 , 2 , 18 , 23 , 59 , 59 , 1_234_567 ) . try_to_rfc2822 ( ) . as_deref ( ) ,
715
+ Some ( "Wed, 18 Feb 2015 23:59:60 +0500" )
714
716
) ;
715
717
assert_eq ! (
716
718
DateTime :: parse_from_rfc2822( "Wed, 18 Feb 2015 23:59:58 +0500" ) ,
@@ -1535,8 +1537,8 @@ fn test_min_max_getters() {
1535
1537
let beyond_max = offset_max. from_utc_datetime ( & NaiveDateTime :: MAX ) ;
1536
1538
1537
1539
assert_eq ! ( format!( "{:?}" , beyond_min) , "-262144-12-31T22:00:00-02:00" ) ;
1538
- // RFC 2822 doesn't support years with more than 4 digits.
1539
- // assert_eq!(beyond_min.to_rfc2822 (), "");
1540
+ # [ cfg ( feature = "alloc" ) ]
1541
+ assert_eq ! ( beyond_min. try_to_rfc2822 ( ) , None ) ; // doesn't support years with more than 4 digits.
1540
1542
#[ cfg( feature = "alloc" ) ]
1541
1543
assert_eq ! ( beyond_min. to_rfc3339( ) , "-262144-12-31T22:00:00-02:00" ) ;
1542
1544
#[ cfg( feature = "alloc" ) ]
@@ -1560,8 +1562,8 @@ fn test_min_max_getters() {
1560
1562
assert_eq ! ( beyond_min. nanosecond( ) , 0 ) ;
1561
1563
1562
1564
assert_eq ! ( format!( "{:?}" , beyond_max) , "+262143-01-01T01:59:59.999999999+02:00" ) ;
1563
- // RFC 2822 doesn't support years with more than 4 digits.
1564
- // assert_eq!(beyond_max.to_rfc2822 (), "");
1565
+ # [ cfg ( feature = "alloc" ) ]
1566
+ assert_eq ! ( beyond_max. try_to_rfc2822 ( ) , None ) ; // doesn't support years with more than 4 digits.
1565
1567
#[ cfg( feature = "alloc" ) ]
1566
1568
assert_eq ! ( beyond_max. to_rfc3339( ) , "+262143-01-01T01:59:59.999999999+02:00" ) ;
1567
1569
#[ cfg( feature = "alloc" ) ]
0 commit comments