sqlalchemy_types.py 文件源码

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

项目:gnocchi 作者: gnocchixyz 项目源码 文件源码
def _dt_to_decimal(utc):
        """Datetime to Decimal.

        Some databases don't store microseconds in datetime
        so we always store as Decimal unixtime.
        """
        if utc is None:
            return None

        decimal.getcontext().prec = 30
        return (decimal.Decimal(str(calendar.timegm(utc.utctimetuple()))) +
                (decimal.Decimal(str(utc.microsecond)) /
                 decimal.Decimal("1000000.0")))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号