Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #67793
| Date | 2014-03-05 04:11 +0000 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: Proper conversion of timestamp |
| References | (1 earlier) <lf5hes$ve3$1@ger.gmane.org> <CA+FnnTxuiNTeaTu7LEdPWvsSnbbirgXqaCS67p5HOrruQPcZ9A@mail.gmail.com> <5316730B.3080706@mrabarnett.plus.com> <CA+FnnTyvXW83OR-L78Xqx5gttv1BANiNHUGh7r5XFJkJ-bGedA@mail.gmail.com> <85siqxfk6s.fsf@benfinney.id.au> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7788.1393992667.18130.python-list@python.org> (permalink) |
On 2014-03-05 02:33, Ben Finney wrote: > Igor Korot <ikorot01@gmail.com> writes: > >> On Tue, Mar 4, 2014 at 4:42 PM, MRAB <python@mrabarnett.plus.com> wrote: >> >> But this particular question is easy. >> >> >> >> What I have is a timestamp which reads: 1289410678L. >> >> >> > That's an integer. It looks like the timestamp is a whole number of >> > seconds, so the number of milliseconds is 0. (I make it '2010-11-10 >> > 17:37:58'.) >> >> Well it is this particular timestamp. > > Which is what you presented as “what I have”. > I'd expect all of the timestamps to be the same type. That example is an integer (a 'long' to be exact). >> But I have a lot of files to process and some do have a timestamp with >> the milliseconds. > > So, if you want help with such timestamps, you'll need to present a real > example (or preferably several exmaples) of timestamps that need this > handling. > >> Right. >> The question is: how to get the number of milliseconds out of >> timestamp? > > From the timestamp you showed: The number of milliseconds is zero, since > it's an integer. That datatype will *always* have zero milliseconds. > >> Once again: I can get the datetime object with the seconds precision >> by dividing it on 1000. But that will produce the datetime object with >> the seconds precision. > > Because that's the data you're showing us: A timestamp with an integer > number of seconds. > And in Python 2, an integer divided by an integer gives an integer. >> I can actually produce another timestamp with the milliseconds from a >> different file... > > Then you won't be able to represent it as an integer number of seconds. > What are you receiving in the data? What data type is it? >
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Proper conversion of timestamp MRAB <python@mrabarnett.plus.com> - 2014-03-05 04:11 +0000
csiph-web