Converting Time question

2006-03-28 Thread Math
Hello PythonPeople..

Can anybody help me out?
How do I convert a time of day from milliseconds?
For example:
I got the following time in milliseconds: 1,090516451769E+15
And I want to print it like: 17:14:11.769
I'm on WinXP
Time zone: GMT +01:00

Thank you all!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting Time question

2006-03-28 Thread Math
Me again..
I guess I ask it wrong..
I measure a time at racing events.this tracktime is measures in the format 
hh:mm:ssDDD
where DDD = thousands of a second...like 17:14:11.769
This format is being saved as a number of micro seconds since 1970..
like 1,090516451769E+15
How do I convert from the micros seconds back to time format above?

thanks again
Hope someone can help me out..




 Hello PythonPeople..

 Can anybody help me out?
 How do I convert a time of day from milliseconds?
 For example:
 I got the following time in milliseconds: 1,090516451769E+15
 And I want to print it like: 17:14:11.769
 I'm on WinXP
 Time zone: GMT +01:00

 Thank you all!
 -- 
 http://mail.python.org/mailman/listinfo/python-list 

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting Time question

2006-03-28 Thread Sybren Stuvel
Math enlightened us with:
 How do I convert a time of day from milliseconds?

Milliseconds since what?

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting Time question

2006-03-28 Thread Sybren Stuvel
Math enlightened us with:
 I measure a time at racing events.this tracktime is measures in the format 
 hh:mm:ssDDD
 where DDD = thousands of a second...like 17:14:11.769
 This format is being saved as a number of micro seconds since 1970..
 like 1,090516451769E+15
 How do I convert from the micros seconds back to time format above?

Use the datetime.datetime.fromtimestamp() function, after dividing the
number of milliseconds by 1000 to create seconds.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting Time question

2006-03-28 Thread Nick Craig-Wood
Math [EMAIL PROTECTED] wrote:
  I measure a time at racing events.this tracktime is measures in the format 
  hh:mm:ssDDD
  where DDD = thousands of a second...like 17:14:11.769
  This format is being saved as a number of micro seconds since 1970..
  like 1,090516451769E+15
  How do I convert from the micros seconds back to time format above?

This is probably what you want

 import datetime 
 t=datetime.datetime.fromtimestamp(1.090516451769E+15/1E6)
 t 
datetime.datetime(2004, 7, 22, 18, 14, 11, 769000)
 t.isoformat()
'2004-07-22T18:14:11.769000'
 t.isoformat(' ').split()[1]
'18:14:11.769000'

Note that this converts using the PCs time zone (hence it says 18:14
not 17:14).  You can pass your own timezone in (but it isn't easy!),
or you can use utcfromtimestamp()

 datetime.datetime.utcfromtimestamp(1.090516451769E+15/1E6).isoformat()[-15:]
'17:14:11.769000'

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list