[Python-Dev] datetime.timedelta total_microseconds
chris.barker at noaa.gov
Wed Feb 27 18:18:20 EST 2019
On Wed, Feb 27, 2019 at 3:04 PM Richard Belleville <rbellevi at google.com>
> Timedelta division is quite a nice solution to the problem. However, since
> we're maintaining a python version agnostic library at least until 2020, we
> need a solution that works in python 2 as well.
So you were limited to a py2 solution.
But di you poke around in py3 before posting?
(you should have, python-dev is really about active development, i.e.
python 3 -- but that's not the point here)
> For the moment, we've left the code as in the original snippet.
If you care about microsecond precision for large timeseltas, you may want
to improve that.
I *think* this is the "correct" way to do it:
return td.microseconds + td.seconds * 1000 + td.days * 86400000
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev