[Zope] DateTime.strftime problem
Andreas Jung
lists at andreas-jung.com
Mon Jan 31 01:51:44 EST 2005
--On Montag, 31. Januar 2005 1:38 Uhr -0500 Ron Bickers
<rbickers-list-zope2 at logicetc.com> wrote:
> 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.
>
If you think that this is a bug: file a collector issue preferred with a
patch and unittests if you want to see this
fixed in the next releases.
Andreas
More information about the Zope
mailing list