From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 22 Oct 2022 12:00:26 +0000 (-0700) Subject: [3.11] gh-98378: Add small format string example to strftime comments (GH-98379)... X-Git-Tag: v3.11.1~236 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9713cace26eac16c03e99c863079561ad7b8df1c;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-98378: Add small format string example to strftime comments (GH-98379) (#98395) gh-98378: Add small format string example to strftime comments (GH-98379) A small example of what a full date and time would look like would help a lot of developers who may not realize that they should investigate `time.h`'s `strftime`, run `man strftime`, or click through a series of docs on the python docs before they get to the actual [definition here](https://docs.python.org/3/library/datetime.htmlGH-strftime-and-strptime-format-codes) which still doesn't have an obvious copy-pastable example of "what the heck format does this thing actually expect?". Automerge-Triggered-By: GH:rhettinger (cherry picked from commit 6ccca69d0d313135b2fbb2aa92c69c315be779c6) Co-authored-by: Alex Zvorygin Co-authored-by: Alex Zvorygin Co-authored-by: Alex Waygood --- diff --git a/Lib/datetime.py b/Lib/datetime.py index 00ded32cc3e3..c3c2568f9865 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -1030,7 +1030,11 @@ class date: self._day, self._year) def strftime(self, fmt): - "Format using strftime()." + """ + Format using strftime(). + + Example: "%d/%m/%Y, %H:%M:%S" + """ return _wrap_strftime(self, fmt, self.timetuple()) def __format__(self, fmt):