﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35857	django.utils.timesince.timesince incorrectly handles daylight saving time	Frank Sauerburger	Dana Kim	"timesince computes the time elapsed between two datetimes (d and now) and returns it as a human readable string. The function is intended to show the elapsed time from a user perspective (sitting with a stopwatch in front of the computer). timesince relies on Python's timezone arithmetic, however, there are subtle implementation details for intra- and inter-timezone calculations. See

* Discussion about the topic: https://github.com/python/cpython/issues/116111
* Quiz to illustrate subtle examples: https://quiz.sauerburger.com/dxi7m/ 

Consider the following example around the daylight saving time transition next weekend in Europe. We start at a point in time a, ten minutes later we have a_10, and another 60 minutes later we have a_70.

{{{
from zoneinfo import ZoneInfo
from datetime import datetime
from django.utils.timesince import timesince

berlin = ZoneInfo(""Europe/Berlin"")

a = datetime(2024, 10, 27, 2, 55, tzinfo=berlin)
a_10 = datetime(2024, 10, 27, 2, 5, fold=1, tzinfo=berlin)
a_70 = datetime(2024, 10, 27, 3, 5, tzinfo=berlin)

assert a.isoformat() == '2024-10-27T02:55:00+02:00'
assert a_10.isoformat() == '2024-10-27T02:05:00+01:00'
assert a_70.isoformat() == '2024-10-27T03:05:00+01:00'

assert timesince(a, a_10) == '0\xa0minutes'
assert timesince(a, a_70) == '10\xa0minutes'
}}}

My expectation is that timesince(a, a_10) yields 10 minutes and timesince(a, a_70) yields 70 minutes aligned with what a user with a stopwatch would observe.

I think this can lead to a lot of unexpected behavior in web applications around the DST transition and maybe even exploitable behavior."	Bug	assigned	Utilities	5.0	Normal				Accepted	1	0	0	1	0	0
