【发布时间】:2021-06-22 15:32:30
【问题描述】:
我知道我可以将datetime.datetime 转换为钟摆
from datetime import datetime,timezone
import pendulum
a = datetime(2021,6,1,tzinfo=timezone.utc)
b = pendulum.instance(a)
b.tzinfo.name # the presence of the attribute 'name' means it's a pendulum timezone
type(b.tzinfo) # pendulum.tz.timezone.FixedTimezone
但我有一个独立的 datetime.tzinfo ,是否可以将其转换为 pendulum.tz.timezone.*
a = timezone.utc # well, imagine that it can be any tzinfo
b = pendulum.xxxxx(a) # that gives tome pendum.tz.timezone class
有这样的方法吗?
【问题讨论】: