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)
>>> import datetime >>> now = datetime.datetime(2003, 8, 4, 12, 30, 45) >>> print now 2003-08-04 12:30:45 >>> print repr(now) datetime.datetime(2003,8,4,12,30,45) >>> print type(now) <type 'instance'> >>> print now.year, now.month, now.day 2003 8 4 >>> print now.hour, now.minute, now.second 12 30 45
See its documentation here.
One limitation as a library is that you need to use
datetime.datetime(2004,1,1).now() # work for any version
instead of just
datetime.datetime.now() # python 2.3+
update
======
I add 'staticmethod' expression. Now it works fine.
def now(self=None):
"Return the current date and time as a datetime."
now = t.localtime()
return datetime(now[0],now[1],now[2],now[3],now[4],now[5])
now = staticmethod(now)
Korakot look at this :
Homepage : http://labix.org/python-dateutil
The dateutil module provides powerful extensions to the standard datetime module, available in Python 2.3+. http://labix.org/download/python-dateutil/python-dateutil-1.1.tar.bz2
Features
*
Computing of relative deltas (next month, next year, next monday, last week of month, etc);
*
Computing of relative deltas between two given date and/or datetime objects;
*
Computing of dates based on very flexible recurrence rules, using a superset of the [WWW] iCalendar specification. Parsing of RFC strings is supported as well.
*
Generic parsing of dates in almost any string format;
*
Timezone (tzinfo) implementations for tzfile(5) format files (/etc/localtime, /usr/share/zoneinfo, etc), TZ environment string (in all known formats), iCalendar format files, given ranges (with help from relative deltas), local machine timezone, fixed offset timezone, UTC timezone, and Windows registry-based time zones.
*
Internal up-to-date world timezone information based on Olson's database.
*
Computing of Easter Sunday dates for any given year, using Western, Orthodox or Julian algorithms;
*
More than 400 test cases