Re: How to calculate two time?

2008-10-09 Thread skip

lookon Thank you for your help.It works.  However, I am using Google
lookon App Engine and cannot import dateutil and epsilon.

I don't know how Google App Engine works, but are you not able to install
pure Python modules?

lookon Are there any other ways?

Take a look at the time.strptime function to generate a tuple, then use

t = time.strptime(timestamp, format)
t1 = datetime.datetime(*t[0:6])

Note that with this solution you will have to handle the timezone offset
yourself.

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


Re: How to calculate two time?

2008-10-09 Thread lookon
I have solved the problem. thank you

On Oct 9, 7:20 pm, [EMAIL PROTECTED] wrote:
     lookon Thank you for your help.It works.  However, I am using Google
     lookon App Engine and cannot import dateutil and epsilon.

 I don't know how Google App Engine works, but are you not able to install
 pure Python modules?

     lookon Are there any other ways?

 Take a look at the time.strptime function to generate a tuple, then use

     t = time.strptime(timestamp, format)
     t1 = datetime.datetime(*t[0:6])

 Note that with this solution you will have to handle the timezone offset
 yourself.

 Skip

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


Re: How to calculate two time?

2008-10-09 Thread skip

lookon but can you tell me what format is it?

Read the strftime man page on your computer or Google for strftime or read
the Python docs about the time.strftime function.  (strftime and strptime
strive to have the same set of format characters.)

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


Re: How to calculate two time?

2008-10-09 Thread lookon
but can you tell me what format is it?

in the str there is a float and I can not deal with it
On Oct 9, 7:20 pm, [EMAIL PROTECTED] wrote:
     lookon Thank you for your help.It works.  However, I am using Google
     lookon App Engine and cannot import dateutil and epsilon.

 I don't know how Google App Engine works, but are you not able to install
 pure Python modules?

     lookon Are there any other ways?

 Take a look at the time.strptime function to generate a tuple, then use

     t = time.strptime(timestamp, format)
     t1 = datetime.datetime(*t[0:6])

 Note that with this solution you will have to handle the timezone offset
 yourself.

 Skip

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


Re: How to calculate two time?

2008-10-09 Thread lookon
Thank you for your help.It works.

However, I am using Google App Engine and cannot import dateutil and
epsilon.

Are there any other ways?


On Oct 8, 10:06 pm, [EMAIL PROTECTED] wrote:
     lookon I have two string like 2007-03-27T08:54:43+08:00  how do I get
     lookon the hours between these two time(string format)?

 Look in PyPI for dateutil, then:

      import dateutil.parser
      t1 = dateutil.parser.parse(2007-03-27T08:54:43+08:00)
      t1
     datetime.datetime(2007, 3, 27, 8, 54, 43, tzinfo=tzoffset(None, 28800))
      t2 = dateutil.parser.parse(2007-03-29T10:00:00+02:00)  t2
     datetime.datetime(2007, 3, 29, 10, 0, tzinfo=tzoffset(None, 7200))
      t2 - t1
     datetime.timedelta(2, 25517)

 Skip

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


How to calculate two time?

2008-10-08 Thread lookon
I have two string like 2007-03-27T08:54:43+08:00 
how do I get the hours between these two time(string format)?
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to calculate two time?

2008-10-08 Thread skip

lookon I have two string like 2007-03-27T08:54:43+08:00  how do I get
lookon the hours between these two time(string format)?

Look in PyPI for dateutil, then:

 import dateutil.parser
 t1 = dateutil.parser.parse(2007-03-27T08:54:43+08:00)
 t1
datetime.datetime(2007, 3, 27, 8, 54, 43, tzinfo=tzoffset(None, 28800))
 t2 = dateutil.parser.parse(2007-03-29T10:00:00+02:00)  t2
datetime.datetime(2007, 3, 29, 10, 0, tzinfo=tzoffset(None, 7200))
 t2 - t1
datetime.timedelta(2, 25517)

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


Re: How to calculate two time?

2008-10-08 Thread Jean-Paul Calderone

On Wed, 8 Oct 2008 06:49:10 -0700 (PDT), lookon [EMAIL PROTECTED] wrote:

I have two string like 2007-03-27T08:54:43+08:00 
how do I get the hours between these two time(string format)?


That's ISO 8601 datetime format.  You might use epsilon.extime:

from epsilon.extime import Time
Time.fromISO8601TimeAndDate(2008-10-08T14:05:16.029246+00:00) - 
Time.fromISO8601TimeAndDate(2007-03-27T08:54:43+08:00)
   datetime.timedelta(561, 47433, 29246)

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