[Python-Dev] datetime.timedelta total_microseconds
tahafut at gmail.com
Thu Feb 14 00:35:20 EST 2019
Oops. That isn't the TOTAL microseconds, but just the microseconds portion.
Sorry for the confusion.
On Wed, Feb 13, 2019 at 9:23 PM Henry Chen <tahafut at gmail.com> wrote:
> Looks like timedelta has a microseconds property. Would this work for your
> In : d
> Out: datetime.timedelta(0, 3, 398407)
> In : d.microseconds
> Out: 398407
> On Wed, Feb 13, 2019 at 9:08 PM Richard Belleville via Python-Dev <
> python-dev at python.org> wrote:
>> In a recent code review, the following snippet was called out as
>> reinventing the
>> _MICROSECONDS_PER_SECOND = 1000000
>> def _timedelta_to_microseconds(delta):
>> return int(delta.total_seconds() * _MICROSECONDS_PER_SECOND)
>> The reviewer thought that there must already exist a standard library
>> that fulfills this functionality. After we had both satisfied ourselves
>> that we
>> hadn't simply missed something in the documentation, we decided that we
>> better raise the issue with a wider audience.
>> Does this functionality already exist within the standard library? If
>> not, would
>> a datetime.timedelta.total_microseconds function be a reasonable
>> addition? I
>> would be happy to submit a patch for such a thing.
>> Richard Belleville
>> Python-Dev mailing list
>> Python-Dev at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev