[Zope] DateTime.strftime problem

Ron Bickers rbickers-list-zope2 at logicetc.com
Mon Jan 31 01:38:37 EST 2005


On Sunday 30 January 2005 03:47 am, Ron Bickers wrote:

> I'm running Zope 2.7.4 and I'm trying to format the current time in the
> format "yyyymmddhhmmssZ" (that is with a timezone of UTC), but I can't do
> it.
>
> The DateTime API says that "A DateTime object's methods return values
> based on the timezone context."  This appares to be the case for all
> except strftime().

Ok. Looking into time.strftime(), I can see the difficulty in making this 
work as expected, but I found a way to get what I want.  Don't know why I 
didn't think of it before.

  utc = DateTime('UTC')
  "%4d%02d%02d%02d%02d%02dZ" % utc.parts()[:6]

Not as pretty, but it works.  I guess one can always roll their own strftime 
with string formatting and all the other DateTime methods.

If strftime() is always going to return the time in the local timezone, I 
suggest it be documented in the API since it's inconsistent with the other 
methods.

Thanks!

-- 
Ron


More information about the Zope mailing list