In [1]:
import datetime
In [2]:
dt_naive = datetime.datetime(2018, 12, 31, 5, 0, 30, 1000)
In [3]:
print(dt_naive)
In [4]:
print(dt_naive.tzinfo)
In [5]:
dt_aware = datetime.datetime(2018, 12, 31, 5, 0, 30, 1000,
tzinfo=datetime.timezone.utc)
In [6]:
print(dt_aware)
In [7]:
print(dt_aware.tzinfo)
In [8]:
print(type(dt_aware.tzinfo))
In [9]:
print(datetime.timezone.utc)
In [10]:
print(type(datetime.timezone.utc))
In [11]:
print(issubclass(type(datetime.timezone.utc), datetime.tzinfo))
In [12]:
tz_jst = datetime.timezone(datetime.timedelta(hours=9))
In [13]:
print(tz_jst)
In [14]:
print(type(tz_jst))
In [15]:
tz_jst_name = datetime.timezone(datetime.timedelta(hours=9), name='JST')
In [16]:
print(tz_jst_name)
In [17]:
dt_utc = datetime.datetime(2018, 12, 31, 5, 0, 30, 1000,
tzinfo=datetime.timezone.utc)
In [18]:
print(dt_utc)
In [19]:
print(dt_utc.tzinfo)
In [20]:
dt_jst = datetime.datetime(2018, 12, 31, 5, 0, 30, 1000,
tzinfo=datetime.timezone(datetime.timedelta(hours=9)))
In [21]:
print(dt_jst)
In [22]:
print(dt_jst.tzinfo)