MCPcopy Index your code
hub / github.com/python/cpython / _ts_to_local

Method _ts_to_local

Lib/zoneinfo/_zoneinfo.py:366–397  ·  view source on GitHub ↗

Generate number of seconds since 1970 *in the local time*. This is necessary to easily find the transition times in local time

(trans_idx, trans_list_utc, utcoffsets)

Source from the content-addressed store, hash-verified

364
365 @staticmethod
366 def _ts_to_local(trans_idx, trans_list_utc, utcoffsets):
367 """Generate number of seconds since 1970 *in the local time*.
368
369 This is necessary to easily find the transition times in local time"""
370 if not trans_list_utc:
371 return [[], []]
372
373 # Start with the timestamps and modify in-place
374 trans_list_wall = [list(trans_list_utc), list(trans_list_utc)]
375
376 if len(utcoffsets) > 1:
377 offset_0 = utcoffsets[0]
378 offset_1 = utcoffsets[trans_idx[0]]
379 if offset_1 > offset_0:
380 offset_1, offset_0 = offset_0, offset_1
381 else:
382 offset_0 = offset_1 = utcoffsets[0]
383
384 trans_list_wall[0][0] += offset_0
385 trans_list_wall[1][0] += offset_1
386
387 for i in range(1, len(trans_idx)):
388 offset_0 = utcoffsets[trans_idx[i - 1]]
389 offset_1 = utcoffsets[trans_idx[i]]
390
391 if offset_1 > offset_0:
392 offset_1, offset_0 = offset_0, offset_1
393
394 trans_list_wall[0][i] += offset_0
395 trans_list_wall[1][i] += offset_1
396
397 return trans_list_wall
398
399
400class _ttinfo:

Callers 1

_load_fileMethod · 0.95

Calls 1

listClass · 0.85

Tested by

no test coverage detected