New submission from Paweł Wroniszewski:

I encountered the problem in logging module, but it is broader then that. Have 
a look at the following code:

====
import time
DATE_FORMAT = '%d/%b/%Y %H:%M:%S%z %Z'
print(time.strftime(DATE_FORMAT))
print(time.strftime(DATE_FORMAT,time.localtime()))
====

The first print statement prints the correct time zone offset (in the place of 
%z), while the second prints +0000. It is important, because the logging module 
passes a predifined time_struct to time.strftime to format it - the timezone 
offset is not usable in such case. 

The documentation for time.strftime(format[, t]) reads:
"If t is not provided, the current time as returned by localtime() is used"
but apparently there must be something extra going on under the hood.

I checked that the problem is present in Python 2.7 and 3.2, probably in other 
version as well. Maybe it is platform dependent - I use Ubuntu 12.04 64 bit. 

If you want to change the time zone for testing, just run e.g.:
===
import os
os.environ['TZ'] = 'Asia/Kolkata'
import time
time.tzset()
===

----------
messages: 202200
nosy: pwronisz
priority: normal
severity: normal
status: open
title: Wrong time zone offset, when using time.strftime() with a given 
struct_time
type: behavior
versions: Python 2.7, Python 3.2

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19502>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to