Issue 1560794: strftime('%z') behaving differently with/without time arg. (original) (raw)

According to the documentation, time.strftime will use time.localtime, when no time tuple is provided as argument. So, I wonder if it is desired behavior that %z returns different values in the following two cases:

Python 2.4.3 (#2, Apr 27 2006, 14:43:58) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2 Type "help", "copyright", "credits" or "license" for more information.

import time time.strftime('%Y-%m-%dT%H:%M:%S%z') '2006-09-18T16:12:05+0200' time.strftime('%Y-%m-%dT%H:%M:%S%z', time.localtime()) '2006-09-18T16:12:05+0000'

The first behavior is what I am looking for.

I realize that %z is not documented, so maybe it should be rejected instead of giving surprising results, like above.

This behavior is observed on different Linux systems under different versions of Python, e.g. on Ubuntu Dapper Drake running Python 2.4.3.