Author p-ganssle
Recipients belopolsky, elinaldosoft, michaelanckaert, p-ganssle, serhiy.storchaka
Date 2019-08-22.15:46:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> I would support this addition. The timedelta class already has accessors for days and seconds, why not for hours and minutes? 

The `timedelta.days` and `timedelta.seconds` accessors do not do what is being requested here. The component accessors just give you a given component of the timedelta in its normalized form, so:

    >>> td = timedelta(hours=25, minutes=1, seconds=2)
    >>> td.days
    >>> td.seconds
    >>> td // timedelta(seconds=1)

The reason there is no hours or minutes is that the normalized form of timedelta doesn't have those components. It would be inconsistent to have `hours` and `minutes` give the total duration of the timedelta in the chosen units while `.days` and `.seconds` return just the component of the normalized form.

What's really being asked for here are `total_hours()` and `total_minutes()` methods, and when that has come up in the past (including recently on the python-dev mailing list), we've largely decided that the "divide by the units you want" idiom is sufficient (and in fact better in that you can choose any arbitrary units rather than just the ones that have specific names).
Date User Action Args
2019-08-22 15:46:25p-gansslesetrecipients: + p-ganssle, belopolsky, serhiy.storchaka, michaelanckaert, elinaldosoft
2019-08-22 15:46:25p-gansslesetmessageid: <>
2019-08-22 15:46:25p-gansslelinkissue37914 messages
2019-08-22 15:46:25p-gansslecreate