[Python-checkins] cpython: Issue #9650: List commonly used format codes in time.strftime and time.strptime
alexander.belopolsky
python-checkins at python.org
Wed Oct 3 00:39:29 CEST 2012
http://hg.python.org/cpython/rev/3a0acdc25cca
changeset: 79417:3a0acdc25cca
user: Alexander Belopolsky <alexander.belopolsky at gmail.com>
date: Tue Oct 02 18:39:16 2012 -0400
summary:
Issue #9650: List commonly used format codes in time.strftime and time.strptime docsttings.
files:
Misc/NEWS | 3 +++
Modules/timemodule.c | 28 +++++++++++++++++++++++++---
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -33,6 +33,9 @@
Library
-------
+- Issue #9650: List commonly used format codes in time.strftime and
+ time.strptime docsttings. Original patch by Mike Hoy.
+
- Issue #16034: Fix performance regressions in the new `bz2.BZ2File`
implementation. Initial patch by Serhiy Storchaka.
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -539,6 +539,26 @@
/* wcsftime() doesn't format correctly time zones, see issue #10653 */
# undef HAVE_WCSFTIME
#endif
+#define STRFTIME_FORMAT_CODES \
+"Commonly used format codes:\n\
+\n\
+%Y Year with century as a decimal number.\n\
+%m Month as a decimal number [01,12].\n\
+%d Day of the month as a decimal number [01,31].\n\
+%H Hour (24-hour clock) as a decimal number [00,23].\n\
+%M Minute as a decimal number [00,59].\n\
+%S Second as a decimal number [00,61].\n\
+%z Time zone offset from UTC.\n\
+%a Locale's abbreviated weekday name.\n\
+%A Locale's full weekday name.\n\
+%b Locale's abbreviated month name.\n\
+%B Locale's full month name.\n\
+%c Locale's appropriate date and time representation.\n\
+%I Hour (12-hour clock) as a decimal number [01,12].\n\
+%p Locale's equivalent of either AM or PM.\n\
+\n\
+Other codes may be available on your platform. See documentation for\n\
+the C library strftime function.\n"
#ifdef HAVE_STRFTIME
#ifdef HAVE_WCSFTIME
@@ -683,13 +703,13 @@
#undef time_char
#undef format_time
-
PyDoc_STRVAR(strftime_doc,
"strftime(format[, tuple]) -> string\n\
\n\
Convert a time tuple to a string according to a format specification.\n\
See the library reference manual for formatting codes. When the time tuple\n\
-is not present, current time as returned by localtime() is used.");
+is not present, current time as returned by localtime() is used.\n\
+\n" STRFTIME_FORMAT_CODES);
#endif /* HAVE_STRFTIME */
static PyObject *
@@ -712,7 +732,9 @@
"strptime(string, format) -> struct_time\n\
\n\
Parse a string to a time tuple according to a format specification.\n\
-See the library reference manual for formatting codes (same as strftime()).");
+See the library reference manual for formatting codes (same as\n\
+strftime()).\n\
+\n" STRFTIME_FORMAT_CODES);
static PyObject *
_asctime(struct tm *timeptr)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list