Formatting Time

2005-06-03 Thread Ognjen Bezanov
I never thought id need help with such a thing as time formatting (admittadly i never did it before) but ok, i guess there is a first for everything. I have a float variable representing seconds, and i want to format it like this: 0:00:00 (h:mm:ss) Now search as I might i am finding this quite

RE: Formatting Time

2005-06-03 Thread Andrew Dalke
Coates, Steve (ACHE) wrote: import time t=36100.0 time.strftime('%H:%M:%S',time.gmtime(t)) > '10:01:40' But if t>=24*60*60 then H cycles back to 0 >>> import time >>> t=24*60*60 >>> time.strftime('%H:%M:%S',time.gmtime(t)) '00:00:00' >>> Andrew

Re: Formatting Time

2005-06-03 Thread Thomas Guettler
Am Fri, 03 Jun 2005 09:29:41 +0100 schrieb Ognjen Bezanov: > I never thought id need help with such a thing as time formatting > (admittadly i never did it before) but ok, i guess there is a first for > everything. > > I have a float variable representing seconds, and i want to format it > like t

Re: Formatting Time

2005-06-03 Thread darren kirby
quoth the Ognjen Bezanov: > I never thought id need help with such a thing as time formatting > (admittadly i never did it before) but ok, i guess there is a first for > everything. > > I have a float variable representing seconds, and i want to format it > like this: > > 0:00:00 (h:mm:ss) > > Now

RE: Formatting Time

2005-06-03 Thread Coates, Steve (ACHE)
> -Original Message- > From: Ognjen Bezanov [mailto:[EMAIL PROTECTED] > Sent: 03 June 2005 09:30 > To: python-list@python.org > Subject: Formatting Time > > I never thought id need help with such a thing as time > formatting (admittadly i never did it before) but

Formatting Time

2005-06-03 Thread Ognjen Bezanov
I never thought id need help with such a thing as time formatting (admittadly i never did it before) but ok, i guess there is a first for everything. I have a float variable representing seconds, and i want to format it like this: 0:00:00 (h:mm:ss) Now search as I might i am finding this quite

Re: Formatting Time

2005-06-02 Thread John Machin
[EMAIL PROTECTED] top-posted: > May be > > sec = 2472 "%d:%02d:%02d" % (int(sec/360), int(sec % 360 /60), int(sec % 60)) > > '6:05:12' > Could you possibly have meant 3600 instead of 360? -- http://mail.python.org/mailman/listinfo/python-list

RE: Formatting Time

2005-06-02 Thread rochoa
May be >>> sec = 2472 >>> "%d:%02d:%02d" % (int(sec/360), int(sec % 360 /60), int(sec % 60)) '6:05:12' Regards -Mensaje original- De: Ognjen Bezanov [mailto:[EMAIL PROTECTED] Enviado el: Jueves, 02 de Junio de 2005 03:29 p.m. Para: python-list

Re: Formatting Time

2005-06-02 Thread Andrew Dalke
Ognjen Bezanov wrote: > I have a float variable representing seconds, and i want to format it > like this: > > 0:00:00 (h:mm:ss) >>> def format_secs(t): ... m, s = divmod(t, 60) ... h, m = divmod(m, 60) ... return "%d:%02d:%02d" % (h, m, s) ... >>> format_secs(0) '0:00:00' >>> format_sec

Formatting Time

2005-06-02 Thread Ognjen Bezanov
I never thought id need help with such a thing as time formatting (admittadly i never did it before) but ok, i guess there is a first for everything. I have a float variable representing seconds, and i want to format it like this: 0:00:00 (h:mm:ss) Now search as I might i am finding this quite