[quills-dev] [Collective-checkins] r49995 - quills.remoteblogging/trunk/quills/remoteblogging/browser
Raphael Ritz r.ritz at biologie.hu-berlin.deMon Sep 24 13:03:43 UTC 2007
- Previous message: [quills-dev] [Collective-checkins] r49995 - quills.remoteblogging/trunk/quills/remoteblogging/browser
- Next message: [quills-dev] [Collective-checkins] r49995 - quills.remoteblogging/trunk/quills/remoteblogging/browser
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Tom Lazar wrote: > thanks raphael, > > i just wanted to avoid using this sort of stuff. > while I can understand your sentiments it seems to be the way Python is heading. At least from 2.5 onwards datetime objects have strptime "build in". Quote from http://docs.python.org/lib/datetime-datetime.html strptime( date_string, format) Return a datetime corresponding to date_string, parsed according to format. This is equivalent to datetime(*(time.strptime(date_string, format)[0:6])). ValueError is raised if the date_string and format can't be parsed by time.strptime() or if it returns a value which isn't a time tuple. New in version 2.5. Raphael PS: if you feel uneasy about this you can still factor it out into a utility method (isn't there a quills.utils already) and call this instead. > but that strptime will surely come in handy, i've gotta remember that > one! > > @tim2p: perhaps this approach will help us push DateTime out of > quills.app? > > cheers, > > tom > > On 24.09.2007, at 10:50, Raphael Ritz wrote: > >> quills-dev at lists.etria.com wrote: >>> Author: tomster >>> Date: Sun Sep 23 22:19:20 2007 >>> New Revision: 49995 >>> >> [..] >> >>> i couldn't find any documentation on how to convert >>> xmlrpc.DateTime into DateTime.DateTime >> FWIW >> >> Python 2.4.4 (#2, Apr 12 2007, 21:03:11) >> [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. >>>>> from xmlrpclib import DateTime as xdt >>>>> from time import strptime >>>>> from datetime import datetime >>>>> xmlrpcdt = xdt() >>>>> xmlrpcdt >> <DateTime '20070924T10:44:06' at -482578f4> >>>>> str(xmlrpcdt) >> '20070924T10:44:06' >>>>> datetimedt = datetime(*strptime(str(xmlrpcdt),"%Y%m%dT%H:%M:%S") >>>>> [0:6]) >>>>> datetimedt >> datetime.datetime(2007, 9, 24, 10, 44, 6) >>>>> str(datetimedt) >> '2007-09-24 10:44:06' >> >> Getting from Python's datetime objects to Zope's DateTime >> is left as an easy exercise ;-) >> >> Raphael >> >> _______________________________________________ >> quills-dev mailing list >> quills-dev at lists.etria.com >> http://lists.etria.com/cgi-bin/mailman/listinfo/quills-dev >> >
- Previous message: [quills-dev] [Collective-checkins] r49995 - quills.remoteblogging/trunk/quills/remoteblogging/browser
- Next message: [quills-dev] [Collective-checkins] r49995 - quills.remoteblogging/trunk/quills/remoteblogging/browser
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the quills-dev mailing list