This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: timezone support in strftime methods broken
Type: behavior Stage:
Components: Extension Modules Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Saimadhav.Heblikar, jayanthkoushik, msoulier, ned.deily
Priority: normal Keywords:

Created on 2014-04-28 21:21 by msoulier, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg217424 - (view) Author: Michael P. Soulier (msoulier) Date: 2014-04-28 21:21
msoulier@cappuccino:~$ python
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> now = datetime.now()
>>> now.strftime("%z")
''
>>> import time
>>> time.strftime("%z", time.localtime(time.time()))
'+0000'
>>>

I think those calls should be printing the UTC offset, no?
msg217582 - (view) Author: Jayanth Koushik (jayanthkoushik) Date: 2014-04-30 08:53
This is not an issue with strftime. By default, datetime and time objects are 'navie' and they do not contain timezone info. Nor does the datetime module provide any tzinfo classes of its own. You would need to write a class derived from tzinfo and specify it as the tzinfo attribute for these objects to be timezone aware.
msg217629 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-04-30 16:48
As Jayanth points out, datetime objects are deliberately time zone "naive" by default; please read https://docs.python.org/2/library/datetime.html and https://docs.python.org/2/library/datetime.html#tzinfo-objects for more information.  Also see https://pypi.python.org/pypi/pytz/.
History
Date User Action Args
2022-04-11 14:58:02adminsetgithub: 65579
2014-04-30 16:48:26ned.deilysetstatus: open -> closed

nosy: + ned.deily
messages: + msg217629

resolution: not a bug
2014-04-30 08:53:22jayanthkoushiksetnosy: + jayanthkoushik
messages: + msg217582
2014-04-29 03:58:54Saimadhav.Heblikarsetnosy: + Saimadhav.Heblikar
2014-04-28 21:21:42msouliercreate