hi all! DateTime('2005/04/03 02:01 GMT').toZone('GMT-4') prints: 2005/04/02 22:01:00 GMT-4 ...which is what i expected --------------------------------------------------------------------- DateTime('2005/04/03 02:01 GMT').toZone('GMT-4')\ .strftime('%Y/%m/%d %H:%M %Z') prints: 2005/04/03 04:01 hmm, where's the timezone information gone? to make it short, how can i get a text representation of a DateTime object in a given timezone? thanks in advance! juergen herrmann _______________________________________________________________________
XLhost.de - eXperts in Linux hosting <<
Jürgen Herrmann Bruderwöhrdstraße 15b, DE-93051 Regensburg Fon: +49 (0)700 XLHOSTDE [0700 95467833] Fax: +49 (0)721 151 463027 WEB: http://www.XLhost.de
--On 7. November 2005 14:21:32 +0100 Jürgen Herrmann <Juergen.Herrmann@XLhost.de> wrote:
hi all!
DateTime('2005/04/03 02:01 GMT').toZone('GMT-4')
prints: 2005/04/02 22:01:00 GMT-4 ...which is what i expected --------------------------------------------------------------------- DateTime('2005/04/03 02:01 GMT').toZone('GMT-4')\ .strftime('%Y/%m/%d %H:%M %Z')
prints: 2005/04/03 04:01
Which Zope version? -aj
On Mon November 7 2005 08:21 am, Jürgen Herrmann wrote:
DateTime('2005/04/03 02:01 GMT').toZone('GMT-4')
prints: 2005/04/02 22:01:00 GMT-4 ...which is what i expected --------------------------------------------------------------------- DateTime('2005/04/03 02:01 GMT').toZone('GMT-4')\ .strftime('%Y/%m/%d %H:%M %Z')
prints: 2005/04/03 04:01
hmm, where's the timezone information gone? to make it short, how can i get a text representation of a DateTime object in a given timezone?
strftime() timezone is broken in all versions of Zope that I know of. You can work around it by using the individual functions to get the information. For example (not verified): dt = DateTime('2005/04/03 02:01 GMT').toZone('GMT-4') '%s/%s/%s %s:%s %s' % (dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute, dt.timezone()) or, if you throw the seconds in there and you keep them in the same order, you can just use parts(): '%s/%s/%s %s:%s:%s %s' % (dt.parts()) -- Ron
On Mon November 7 2005 12:15 pm, Ron Bickers wrote:
dt = DateTime('2005/04/03 02:01 GMT').toZone('GMT-4') '%s/%s/%s %s:%s %s' % (dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute, dt.timezone())
'%s/%s/%s %s:%s:%s %s' % (dt.parts())
Uh... you'll probably need to change the format string to suit your needs of leading zeros and such, but you get the idea. -- Ron
On Mon November 7 2005 12:15 pm, Ron Bickers wrote:
dt = DateTime('2005/04/03 02:01 GMT').toZone('GMT-4') '%s/%s/%s %s:%s %s' % (dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute, dt.timezone())
Oops. A (hopefully obvious) typo... should be dt.minute() -- Ron
participants (3)
-
Andreas Jung -
Jürgen Herrmann -
Ron Bickers