@@ -1043,9 +1043,12 @@ def test_time(self):
1043
1043
for t , l in zip (ticks , labels ):
1044
1044
m , s = divmod (int (t ), 60 )
1045
1045
h , m = divmod (m , 60 )
1046
- xp = l .get_text ()
1047
- if len (xp ) > 0 :
1048
- rs = time (h , m , s ).strftime ('%H:%M:%S' )
1046
+ rs = l .get_text ()
1047
+ if len (rs ) > 0 :
1048
+ if s != 0 :
1049
+ xp = time (h , m , s ).strftime ('%H:%M:%S' )
1050
+ else :
1051
+ xp = time (h , m , s ).strftime ('%H:%M' )
1049
1052
assert xp == rs
1050
1053
1051
1054
# change xlim
@@ -1058,9 +1061,12 @@ def test_time(self):
1058
1061
for t , l in zip (ticks , labels ):
1059
1062
m , s = divmod (int (t ), 60 )
1060
1063
h , m = divmod (m , 60 )
1061
- xp = l .get_text ()
1062
- if len (xp ) > 0 :
1063
- rs = time (h , m , s ).strftime ('%H:%M:%S' )
1064
+ rs = l .get_text ()
1065
+ if len (rs ) > 0 :
1066
+ if s != 0 :
1067
+ xp = time (h , m , s ).strftime ('%H:%M:%S' )
1068
+ else :
1069
+ xp = time (h , m , s ).strftime ('%H:%M' )
1064
1070
assert xp == rs
1065
1071
1066
1072
@pytest .mark .slow
@@ -1082,13 +1088,19 @@ def test_time_musec(self):
1082
1088
for t , l in zip (ticks , labels ):
1083
1089
m , s = divmod (int (t ), 60 )
1084
1090
1085
- # TODO: unused?
1086
- # us = int((t - int(t)) * 1e6)
1091
+ us = int (round ((t - int (t )) * 1e6 ))
1087
1092
1088
1093
h , m = divmod (m , 60 )
1089
- xp = l .get_text ()
1090
- if len (xp ) > 0 :
1091
- rs = time (h , m , s ).strftime ('%H:%M:%S.%f' )
1094
+ rs = l .get_text ()
1095
+ if len (rs ) > 0 :
1096
+ if (us % 1000 ) != 0 :
1097
+ xp = time (h , m , s , us ).strftime ('%H:%M:%S.%f' )
1098
+ elif (us // 1000 ) != 0 :
1099
+ xp = time (h , m , s , us ).strftime ('%H:%M:%S.%f' )[:- 3 ]
1100
+ elif s != 0 :
1101
+ xp = time (h , m , s , us ).strftime ('%H:%M:%S' )
1102
+ else :
1103
+ xp = time (h , m , s , us ).strftime ('%H:%M' )
1092
1104
assert xp == rs
1093
1105
1094
1106
@pytest .mark .slow
0 commit comments