File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -657,7 +657,39 @@ fn test_date_tz_with_relative_time() {
657
657
#[ test]
658
658
fn test_date_utc_time ( ) {
659
659
// Test that -u flag shows correct UTC time
660
- new_ucmd ! ( ) . arg ( "-u" ) . arg ( "+%H:%M" ) . succeeds ( ) ;
660
+ // We get 2 UTC times just in case we're really unlucky and this runs around
661
+ // an hour change.
662
+ let utc_hour_1: i32 = new_ucmd ! ( )
663
+ . env ( "TZ" , "Asia/Taipei" )
664
+ . arg ( "-u" )
665
+ . arg ( "+%-H" )
666
+ . succeeds ( )
667
+ . stdout_str ( )
668
+ . trim_end ( )
669
+ . parse ( )
670
+ . unwrap ( ) ;
671
+ let tpe_hour: i32 = new_ucmd ! ( )
672
+ . env ( "TZ" , "Asia/Taipei" )
673
+ . arg ( "+%-H" )
674
+ . succeeds ( )
675
+ . stdout_str ( )
676
+ . trim_end ( )
677
+ . parse ( )
678
+ . unwrap ( ) ;
679
+ let utc_hour_2: i32 = new_ucmd ! ( )
680
+ . env ( "TZ" , "Asia/Taipei" )
681
+ . arg ( "-u" )
682
+ . arg ( "+%-H" )
683
+ . succeeds ( )
684
+ . stdout_str ( )
685
+ . trim_end ( )
686
+ . parse ( )
687
+ . unwrap ( ) ;
688
+ // Taipei is always 8 hours ahead of UTC (no daylight savings)
689
+ assert ! (
690
+ ( tpe_hour - utc_hour_1 + 24 ) % 24 == 8 || ( tpe_hour - utc_hour_2 + 24 ) % 24 == 8 ,
691
+ "TPE: {tpe_hour} UTC: {utc_hour_1}/{utc_hour_2}"
692
+ ) ;
661
693
662
694
// Test that -u flag shows UTC timezone
663
695
new_ucmd ! ( )
You can’t perform that action at this time.
0 commit comments