add 'd' conversion for format strings
to convert a timestamp to a formattable 'datetime' object.
For example '{created_at!d:%Y-%m-%d}'
transforms the timestamp in 'created_at' into a 'datetime' object
and then formats its content using '%Y-%m-%d' as template.
1262304000 -> datetime(2010, 1, 1) -> "2010-01-01"
This commit is contained in:
@@ -506,6 +506,7 @@ class Formatter():
|
||||
- "c": calls str.capitalize
|
||||
- "C": calls string.capwords
|
||||
- "t": calls str.strip
|
||||
- "d": calls text.parse_timestamp
|
||||
- "U": calls urllib.parse.unquote
|
||||
- "S": calls util.to_string()
|
||||
- Example: {f!l} -> "example"; {f!u} -> "EXAMPLE"
|
||||
@@ -537,6 +538,7 @@ class Formatter():
|
||||
"c": str.capitalize,
|
||||
"C": string.capwords,
|
||||
"t": str.strip,
|
||||
"d": text.parse_timestamp,
|
||||
"U": urllib.parse.unquote,
|
||||
"S": to_string,
|
||||
"s": str,
|
||||
|
||||
Reference in New Issue
Block a user