Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70493

Re: How to properly get the microseconds from the timestamps?

References <CA+FnnTyz_OHTf74FA7VO6NkQ81+CWWsJcKe8+F4_LPinq=S4pQ@mail.gmail.com>
Date 2014-04-22 11:15 +0200
Subject Re: How to properly get the microseconds from the timestamps?
From Vlastimil Brom <vlastimil.brom@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.9429.1398158127.18130.python-list@python.org> (permalink)

Show all headers | View raw


2014-04-22 4:38 GMT+02:00 Igor Korot <ikorot01@gmail.com>:
...
>>>> datetime.datetime.fromtimestamp(1092787200/1000.0)
> datetime.datetime(1970, 1, 13, 7, 33, 7, 200000)
>
> Is there a way to know if the timestamp has a microseconds?
>
> Thank you.
> --
Hi,
I believe, in these cases, you can just test, whether there is a
non-integer part in the timestamp in seconds, which will be stored as
microseconds accordingly.
>>> 1092787200/1000.0
1092787.2
0.2 s is stored (and shown in repr(...)) as  200000  microseconds.

There are some peculiarities in handling date and time calculations
reliably as well as in the floating point math, but they don't seem to
be involved here.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How to properly get the microseconds from the timestamps? Vlastimil Brom <vlastimil.brom@gmail.com> - 2014-04-22 11:15 +0200

csiph-web