Paul Ganssle <p.gans...@gmail.com> added the comment:

> 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).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37914>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to