4545TIME_ZONE_STRING_UTC = "Z"
4646TIME_ZONE_UTC_UTC_OFFSET = (0 , 0 )
4747TIME_ZONE_LOCAL_UTC_OFFSET = get_local_time_zone ()
48- TIME_ZONE_LOCAL_UTC_OFFSET_HOURS = TIME_ZONE_LOCAL_UTC_OFFSET [0 ]
49- TIME_ZONE_LOCAL_UTC_OFFSET_MINUTES = TIME_ZONE_LOCAL_UTC_OFFSET [1 ]
5048
5149TIME_ZONE_LOCAL_INFO = {
5250 "hours" : TIME_ZONE_LOCAL_UTC_OFFSET [0 ],
@@ -151,8 +149,7 @@ def get_time_string(date_time, display_sub_seconds=False,
151149 else :
152150 custom_string = custom_time_zone_info ["string_extended" ]
153151 if date_time_is_local :
154- date_time_hours = TIME_ZONE_LOCAL_UTC_OFFSET_HOURS
155- date_time_minutes = TIME_ZONE_LOCAL_UTC_OFFSET_MINUTES
152+ date_time_hours , date_time_minutes = TIME_ZONE_LOCAL_UTC_OFFSET
156153 else :
157154 date_time_hours , date_time_minutes = (0 , 0 )
158155 diff_hours = custom_hours - date_time_hours
@@ -163,18 +160,15 @@ def get_time_string(date_time, display_sub_seconds=False,
163160 elif override_use_utc or (override_use_utc is None and _FLAGS ['utc_mode' ]):
164161 time_zone_string = TIME_ZONE_STRING_UTC
165162 if date_time_is_local :
166- date_time = date_time - timedelta (
167- hours = TIME_ZONE_LOCAL_UTC_OFFSET_HOURS ,
168- minutes = TIME_ZONE_LOCAL_UTC_OFFSET_MINUTES
169- )
163+ h , m = TIME_ZONE_LOCAL_UTC_OFFSET
164+ date_time = date_time - timedelta (hours = h , minutes = m )
170165 else :
171166 if use_basic_format :
172167 time_zone_string = TIME_ZONE_STRING_LOCAL_BASIC
173168 else :
174169 time_zone_string = TIME_ZONE_STRING_LOCAL_EXTENDED
175170 if not date_time_is_local :
176- diff_hours = TIME_ZONE_LOCAL_UTC_OFFSET_HOURS
177- diff_minutes = TIME_ZONE_LOCAL_UTC_OFFSET_MINUTES
171+ diff_hours , diff_minutes = TIME_ZONE_LOCAL_UTC_OFFSET
178172 date_time = date_time + timedelta (
179173 hours = diff_hours , minutes = diff_minutes )
180174 if use_basic_format :
0 commit comments