Skip to content

Commit 6a49f26

Browse files
committed
Fix issues with timezones
1 parent 8ffdba4 commit 6a49f26

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

cylc/flow/wallclock.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,16 @@
3737
TIME_FORMAT_EXTENDED = "%H:%M:%S"
3838
TIME_FORMAT_EXTENDED_SUB_SECOND = "%H:%M:%S.%f"
3939

40-
TIME_ZONE_STRING_LOCAL_BASIC = get_local_time_zone_format(
41-
TimeZoneFormatMode.reduced)
42-
TIME_ZONE_STRING_LOCAL_EXTENDED = get_local_time_zone_format(
43-
TimeZoneFormatMode.extended)
4440
TIME_ZONE_STRING_UTC = "Z"
4541
TIME_ZONE_UTC_UTC_OFFSET = (0, 0)
46-
TIME_ZONE_LOCAL_UTC_OFFSET = get_local_time_zone()
47-
TIME_ZONE_LOCAL_UTC_OFFSET_HOURS = TIME_ZONE_LOCAL_UTC_OFFSET[0]
48-
TIME_ZONE_LOCAL_UTC_OFFSET_MINUTES = TIME_ZONE_LOCAL_UTC_OFFSET[1]
4942

5043
TIME_ZONE_LOCAL_INFO = {
51-
"hours": TIME_ZONE_LOCAL_UTC_OFFSET[0],
52-
"minutes": TIME_ZONE_LOCAL_UTC_OFFSET[1],
53-
"string_basic": TIME_ZONE_STRING_LOCAL_BASIC,
54-
"string_extended": TIME_ZONE_STRING_LOCAL_EXTENDED
44+
"hours": get_local_time_zone()[0],
45+
"minutes": get_local_time_zone()[1],
46+
"string_basic": get_local_time_zone_format(
47+
TimeZoneFormatMode.reduced),
48+
"string_extended": get_local_time_zone_format(
49+
TimeZoneFormatMode.extended)
5550
}
5651

5752
TIME_ZONE_UTC_INFO = {
@@ -149,8 +144,8 @@ def get_time_string(date_time, display_sub_seconds=False,
149144
else:
150145
custom_string = custom_time_zone_info["string_extended"]
151146
if date_time_is_local:
152-
date_time_hours = TIME_ZONE_LOCAL_UTC_OFFSET_HOURS
153-
date_time_minutes = TIME_ZONE_LOCAL_UTC_OFFSET_MINUTES
147+
date_time_hours = get_local_time_zone()[0]
148+
date_time_minutes = get_local_time_zone()[1]
154149
else:
155150
date_time_hours, date_time_minutes = (0, 0)
156151
diff_hours = custom_hours - date_time_hours
@@ -162,17 +157,19 @@ def get_time_string(date_time, display_sub_seconds=False,
162157
time_zone_string = TIME_ZONE_STRING_UTC
163158
if date_time_is_local:
164159
date_time = date_time - timedelta(
165-
hours=TIME_ZONE_LOCAL_UTC_OFFSET_HOURS,
166-
minutes=TIME_ZONE_LOCAL_UTC_OFFSET_MINUTES
160+
hours=get_local_time_zone()[0],
161+
minutes=get_local_time_zone()[1]
167162
)
168163
else:
169164
if use_basic_format:
170-
time_zone_string = TIME_ZONE_STRING_LOCAL_BASIC
165+
time_zone_string = get_local_time_zone_format(
166+
TimeZoneFormatMode.reduced)
171167
else:
172-
time_zone_string = TIME_ZONE_STRING_LOCAL_EXTENDED
168+
time_zone_string = get_local_time_zone_format(
169+
TimeZoneFormatMode.extended)
173170
if not date_time_is_local:
174-
diff_hours = TIME_ZONE_LOCAL_UTC_OFFSET_HOURS
175-
diff_minutes = TIME_ZONE_LOCAL_UTC_OFFSET_MINUTES
171+
diff_hours = get_local_time_zone()[0]
172+
diff_minutes = get_local_time_zone()[1]
176173
date_time = date_time + timedelta(
177174
hours=diff_hours, minutes=diff_minutes)
178175
if use_basic_format:

0 commit comments

Comments
 (0)