converter.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:snowflake-connector-python 作者: snowflakedb 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号