File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -1132,6 +1132,52 @@ fn test_date_military_timezone_with_offset_variations() {
11321132 }
11331133}
11341134
1135+ #[ test]
1136+ fn test_date_military_timezone_with_offset_and_date ( ) {
1137+ use chrono:: { Duration , Utc } ;
1138+
1139+ let today = Utc :: now ( ) . date_naive ( ) ;
1140+
1141+ let test_cases = vec ! [
1142+ ( "m" , -1 ) , // M = UTC+12
1143+ ( "a" , -1 ) , // A = UTC+1
1144+ ( "n" , 0 ) , // N = UTC-1
1145+ ( "y" , 0 ) , // N = UTC-12
1146+ ( "z" , 0 ) , // Z = UTC
1147+
1148+ // same day hour offsets
1149+ ( "n2" , 0 ) ,
1150+
1151+ // midnight crossings with hour offsets back to today
1152+ ( "a1" , 0 ) , // exactly to midnight
1153+ ( "a5" , 0 ) , // "overflow" midnight
1154+ ( "m23" , 0 ) ,
1155+
1156+ // midnight crossings with hour offsets to tomorrow
1157+ ( "n23" , 1 ) ,
1158+ ( "y23" , 1 ) ,
1159+ ] ;
1160+
1161+ for ( input, day_delta) in test_cases {
1162+ let expected_date = today
1163+ . checked_add_signed ( Duration :: days ( day_delta) )
1164+ . unwrap ( ) ;
1165+
1166+ let expected = format ! (
1167+ "{}\n " ,
1168+ expected_date. format( "%F" ) ,
1169+ ) ;
1170+
1171+ new_ucmd ! ( )
1172+ . env ( "TZ" , "UTC" )
1173+ . arg ( "-d" )
1174+ . arg ( input)
1175+ . arg ( "+%F" )
1176+ . succeeds ( )
1177+ . stdout_is ( expected) ;
1178+ }
1179+ }
1180+
11351181// Locale-aware hour formatting tests
11361182#[ test]
11371183#[ cfg( unix) ]
You can’t perform that action at this time.
0 commit comments