-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimezone.py
45 lines (41 loc) · 1.72 KB
/
timezone.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Poland DST periods
# datetime start in UTC datetime end in UTC timezone
# 2022-10-30 01:00:00+00:00 2023-03-26 01:00:00+00:00 CET
# 2023-03-26 01:00:00+00:00 2023-10-29 01:00:00+00:00 CEST
# 2023-10-29 01:00:00+00:00 2024-03-31 01:00:00+00:00 CET
# 2024-03-31 01:00:00+00:00 2024-10-27 01:00:00+00:00 CEST
# 2024-10-27 01:00:00+00:00 2025-03-30 01:00:00+00:00 CET
# 2025-03-30 01:00:00+00:00 2025-10-26 01:00:00+00:00 CEST
# 2025-10-26 01:00:00+00:00 2026-03-29 01:00:00+00:00 CET
# 2026-03-29 01:00:00+00:00 2026-10-25 01:00:00+00:00 CEST
# 2026-10-25 01:00:00+00:00 2027-03-28 01:00:00+00:00 CET
# 2027-03-28 01:00:00+00:00 2027-10-31 01:00:00+00:00 CEST
# 2027-10-31 01:00:00+00:00 2028-03-26 01:00:00+00:00 CET
# 2028-03-26 01:00:00+00:00 2028-10-29 01:00:00+00:00 CEST
# 2028-10-29 01:00:00+00:00 2029-03-25 01:00:00+00:00 CET
# 2029-03-25 01:00:00+00:00 2029-10-28 01:00:00+00:00 CEST
CET = +1
CEST = +2
POLAND_TIMEZONES = (
# start unixtimestamp, end unixtimestamp, timezone
(1667091600, 1679792400, CET),
(1679792400, 1698541200, CEST),
(1698541200, 1711846800, CET),
(1711846800, 1729990800, CEST),
(1729990800, 1743296400, CET),
(1743296400, 1761440400, CEST),
(1761440400, 1774746000, CET),
(1774746000, 1792890000, CEST),
(1792890000, 1806195600, CET),
(1806195600, 1824944400, CEST),
(1824944400, 1837645200, CET),
(1837645200, 1856394000, CEST),
(1856394000, 1869094800, CET),
(1869094800, 1887843600, CEST),
)
def get_current_timezone(unixtime):
for timestamp_start, timestamp_end, timezone in POLAND_TIMEZONES:
if timestamp_start < unixtime <= timestamp_end:
return timezone
return CET
# raise RuntimeError('No DST data for current time')