-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path132 awaretime.py
27 lines (20 loc) · 920 Bytes
/
132 awaretime.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
import datetime
import pytz
local_time = datetime.datetime.now()
utc_time = datetime.datetime.utcnow()
print("Czas lokalny {}".format(local_time))
print("Czas UTC {}".format(utc_time))
aware_local_time = pytz.utc.localize(local_time).astimezone()
aware_utc_time = pytz.utc.localize(utc_time)
print("Czas lokalny aware {}, strefa czasowa {} ".format(aware_local_time, aware_local_time.tzinfo))
print("Czas UTC aware {}, strefa czasowa {} ".format(aware_utc_time, aware_utc_time.tzinfo))
gap_time = datetime.datetime(2015, 10, 25, 1, 30, 0, 0)
print(gap_time)
print(gap_time.timestamp())
s = 1445733000
t = s + (60 * 60)
gb = pytz.timezone("GB")
dt1 = pytz.utc.localize(datetime.datetime.utcfromtimestamp(s)).astimezone(gb)
dt2 = pytz.utc.localize(datetime.datetime.utcfromtimestamp(t)).astimezone(gb)
print("{} seconds since the epoch is {}".format(s, dt1))
print("{} seconds since the epoch is {}".format(t, dt2))