Django 时区同一天差异不为 0

Django timezone same day diff is not 0

测试函数

from django.utils import timezone

def date_diff_now(date):
    print(date)
    print(timezone.now())
    print(date - timezone.now())
    print((date - timezone.now()).days)

结果

2018-02-07 17:46:36.442314+00:00
2018-02-07 17:47:32.084900+00:00
-1 day, 23:59:04.357374
-1

为什么同一天的 2 个日期时间之间的差异不是 return 0?

来自Basic time and dates

If the normalized value of days lies outside the indicated range, OverflowError is raised.

Note that normalization of negative values may be surprising at first. For example,

>>> from datetime import timedelta
>>> d = timedelta(microseconds=-1)
>>> (d.days, d.seconds, d.microseconds)
(-1, 86399, 999999)

所以它看起来像是一个已知的溢出错误。