Using datetime in python 2.2 (e.g. pys60)
There's a small compatible library from the Python Web Project.
I download the source and extract the datetime.py then
send it to my phone as a pys60 library.
Here's a simple test that works well.
(Taken from Effbot)
1 2 >>> import datetime 3 >>> now = datetime.datetime(2003, 8, 4, 12, 30, 45) 4 >>> print now 5 2003-08-04 12:30:45 6 >>> print repr(now) 7 datetime.datetime(2003,8,4,12,30,45) 8 >>> print type(now) 9 <type 'instance'> 10 >>> print now.year, now.month, now.day 11 2003 8 4 12 >>> print now.hour, now.minute, now.second 13 12 30 45
See its documentation here.
One limitation as a library is that you need to use
1 datetime.datetime(2004,1,1).now() # work for any version
instead of just
1 datetime.datetime.now() # python 2.3+
update
======
I add 'staticmethod' expression. Now it works fine.
1 2 def now(self=None): 3 "Return the current date and time as a datetime." 4 now = t.localtime() 5 return datetime(now[0],now[1],now[2],now[3],now[4],now[5]) 6 now = staticmethod(now)