def _derive_offset_timestamp(self, value, is_utc=False):
"""
Derives TZ offset and timestamp from the datatime object
"""
tzinfo = value.tzinfo
if tzinfo is None:
# If no tzinfo is attached, use local timezone.
tzinfo = self._get_session_tz() if not is_utc else pytz.UTC
t = pytz.utc.localize(value, is_dst=False).astimezone(tzinfo)
else:
# if tzinfo is attached, just covert to epoch time
# as the server expects it in UTC anyway
t = value
offset = tzinfo.utcoffset(
t.replace(tzinfo=None)).total_seconds() / 60 + 1440
return offset, t
converter.py 文件源码
python
阅读 31
收藏 0
点赞 0
评论 0
评论列表
文章目录