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


Groups > comp.lang.python > #67793 > unrolled thread

Re: Proper conversion of timestamp

Started byMRAB <python@mrabarnett.plus.com>
First post2014-03-05 04:11 +0000
Last post2014-03-05 04:11 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Proper conversion of timestamp MRAB <python@mrabarnett.plus.com> - 2014-03-05 04:11 +0000

#67793 — Re: Proper conversion of timestamp

FromMRAB <python@mrabarnett.plus.com>
Date2014-03-05 04:11 +0000
SubjectRe: Proper conversion of timestamp
Message-ID<mailman.7788.1393992667.18130.python-list@python.org>
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?
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web