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: strftime docs do not explain locale effect on result string
Type: Stage: resolved
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: barry-scott, belopolsky, docs@python, eric.araujo, ezio.melotti, georg.brandl, math_foo, python-dev, r.david.murray, vstinner, wolever
Priority: normal Keywords: easy, patch

Created on 2009-05-02 13:25 by barry-scott, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue5904.patch math_foo, 2014-04-17 00:25 Update docs for strftime specifying that it returns a locale dependent byte string. review
Messages (7)
msg86946 - (view) Author: Barry Alan Scott (barry-scott) * Date: 2009-05-02 13:25
The result of time.strftime seems to be in the locale encoding
but this is not pointed out in the documentation.

Ideally an example like this would be in the docs to show how to
deal with strftime output:

import locale
import time

locale_encoded_time = time.strftime( '%d-%b-%Y %H:%M:%S' )

language, encoding = locale.getdefaultlocale()
unicode_time = locale_encoded_time.decode( encoding )
msg108165 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-06-19 03:46
Victor, this is your chance to add French to Python docs!
msg216628 - (view) Author: Caelyn McAulay (math_foo) Date: 2014-04-17 00:25
Added to Docs that strftime will return a locale dependent byte string.
msg216659 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-04-17 06:02
This may help: http://blog.codekills.net/2013/04/13/strftime--table-of-locale-aware-formatters-in-different-locales/
msg216661 - (view) Author: David Wolever (wolever) * (Python committer) Date: 2014-04-17 06:23
It may also be worth noting that the strftime formatters table now includes examples from different locales: https://docs.python.org/2/library/datetime.html#strftime-strptime-behavior

This change was introduced about a year ago.
msg220502 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-06-13 21:23
New changeset 31adcc4c4391 by R David Murray in branch '2.7':
#5904: Add sentence about the encoding of strftime's result.
http://hg.python.org/cpython/rev/31adcc4c4391
msg220503 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-06-13 21:25
Thanks, Caelyn.  I used your patch but added a clause showing explicitly how do the unicode conversion.  I decided to not add that to the datetime, docs, since they are already pretty clear.
History
Date User Action Args
2022-04-11 14:56:48adminsetgithub: 50154
2014-06-13 21:25:23r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg220503

resolution: fixed
stage: needs patch -> resolved
2014-06-13 21:23:47python-devsetnosy: + python-dev
messages: + msg220502
2014-04-17 06:23:14woleversetmessages: + msg216661
2014-04-17 06:02:31eric.araujosetnosy: + wolever
messages: + msg216659
2014-04-17 00:25:08math_foosetfiles: + issue5904.patch

nosy: + math_foo
messages: + msg216628

keywords: + patch
2011-11-08 21:15:49ezio.melottisetnosy: + ezio.melotti
stage: needs patch

versions: + Python 2.7, - Python 2.6
2010-08-26 21:22:12eric.araujosetassignee: georg.brandl -> docs@python

nosy: + docs@python
2010-07-31 22:06:51georg.brandlsettitle: strftime docs do not explain locale affect on result string -> strftime docs do not explain locale effect on result string
2010-06-19 03:46:28belopolskysetkeywords: + easy
nosy: + belopolsky, vstinner
messages: + msg108165

2010-02-16 06:16:39eric.araujosetnosy: + eric.araujo
2009-05-02 13:25:37barry-scottcreate