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 <1566488785.38.0.805722513539.issue37914@roundup.psfhosted.org>
In-reply-to
Content
> 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
    1
    >>> td.seconds
    3662
    >>> td // timedelta(seconds=1)
    90062


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).
History
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: <1566488785.38.0.805722513539.issue37914@roundup.psfhosted.org>
2019-08-22 15:46:25p-gansslelinkissue37914 messages
2019-08-22 15:46:25p-gansslecreate