Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

Loris Bennett loris.bennett at fu-berlin.de
Tue Apr 19 10:19:49 EDT 2022


Jon Ribbens <jon+usenet at unequivocal.eu> writes:

> On 2022-04-19, Loris Bennett <loris.bennett at fu-berlin.de> wrote:
>> If I am merely trying to represent part a very large number of seconds
>> as a number of years, 365 days per year does not seem that controversial
>> to me.  Obviously there are issues if you expect all periods of an
>> integer number of years which start on a given date to all end on the
>> same date.
>>
>> In my little niche, I just need a very simple period and am anyway not
>> bothered about years, since in my case the number of days is usually
>> capped at 14 and only in extremely exceptional circumstances could it
>> get up to anywhere near 100.
>>
>> However, surely there are plenty of people measuring durations of a few
>> hours or less who don't want to have to deal with seconds all the time
>> (I am in fact also in this other group when I record my working hours).
>
> Well, that's my point. Everyone's all in their own slightly-different
> little niches. There isn't one straightforward standard that makes all
> or even most of them happy.

I'm sure you're right.  I just strikes me as a little odd that so much
effort has gone into datetime to make things work (almost) properly for
(almost) everyone, whereas timedelta has remained rather rudimentary, at
least in terms of formatting.  It seems to me that periods on the order
of hours would have quite generic applications, but maybe that's just
the view from my niche.

Cheers,

Loris

-- 
This signature is currently under construction.


More information about the Python-list mailing list