stftime %z time conversion character
evan at yelp.com
Wed Jun 20 06:20:39 CEST 2007
On 6/19/07, Paul Boddie <paul at boddie.org.uk> wrote:
> Evan Klitzke wrote:
> > Although it is not present in ANSI C, the GNU version of stftime
> > supports the conversion character %z, which is a time offset from GMT.
> > The four digit time offset is required in RFC 2822 dates/times, and is
> > used by a number of other programs as well. I need to convert times
> > that use this convention to python time representations, and because
> > Python does not support the %z time conversion character I cannot
> > simply use the time.strptime function.
> See this patch for an idea of the scope of this problem:
> > What solutions have people used for this? I'm currently thinking of
> > creating a dict that maps four digit time offsets to the time zone
> > name and then use the %Z token on that. Is there another (or better)
> > way?
> Apart from a patch which would allow the time module functions to
> produce the output you desire, an alternative might involve the
> datetime module and timezone-aware datetime objects:
> I refer indirectly to the pytz module in the above message:
Thanks Paul, your answer was very helpful.
Evan Klitzke <evan at yelp.com>
More information about the Python-list