#35857: django.utils.timesince.timesince incorrectly handles daylight saving
time
-----------------------------------+------------------------------------
Reporter: Frank Sauerburger | Owner: (none)
Type: Bug | Status: new
Component: Utilities | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Sarah Boyce):
* component: Uncategorized => Utilities
* stage: Unreviewed => Accepted
* type: Uncategorized => Bug
Comment:
If I understood correctly, I think the example was meant to show:
{{{#!python
a = datetime(2024, 10, 27, 2, 55, tzinfo=berlin)
a_10 = datetime(2024, 10, 27, 3, 5, fold=0, tzinfo=berlin)
a_70 = datetime(2024, 10, 27, 3, 5, fold=1, tzinfo=berlin)
assert timesince(a, a_10) == '10\xa0minutes'
assert timesince(a, a_70) == '10\xa0minutes' # expected 1 hour 10 minutes
}}}
For those not familiar with
[https://docs.python.org/3/library/datetime.html#datetime.datetime.fold
fold], this is used to disambiguate wall times during a repeated interval.
The values 0 and 1 represent, respectively, the earlier and later of the
two moments with the same wall time representation.
Looking at the
[https://github.com/python/cpython/issues/116111#issuecomment-2335918369
discussion], it appears timesince should convert the dates to UTC before
subtracting them.
Linking #34483 as this is slightly related
--
Ticket URL: <https://code.djangoproject.com/ticket/35857#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070192b35a2504-b116efe1-2346-4b72-92f1-e2803516f2c5-000000%40eu-central-1.amazonses.com.