Skip to content

Commit 0ace5f8

Browse files
authored
Document new timestamp format style
1 parent e2cf721 commit 0ace5f8

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

discord/utils.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,31 +1223,35 @@ def is_inside_class(func: Callable[..., Any]) -> bool:
12231223
return not remaining.endswith('<locals>')
12241224

12251225

1226-
TimestampStyle = Literal['f', 'F', 'd', 'D', 't', 'T', 'R']
1226+
TimestampStyle = Literal['f', 'F', 'd', 'D', 't', 'T', 's', 'S', 'R']
12271227

12281228

12291229
def format_dt(dt: datetime.datetime, /, style: Optional[TimestampStyle] = None) -> str:
12301230
"""A helper function to format a :class:`datetime.datetime` for presentation within Discord.
12311231
12321232
This allows for a locale-independent way of presenting data using Discord specific Markdown.
12331233
1234-
+-------------+----------------------------+-----------------+
1235-
| Style | Example Output | Description |
1236-
+=============+============================+=================+
1237-
| t | 22:57 | Short Time |
1238-
+-------------+----------------------------+-----------------+
1239-
| T | 22:57:58 | Long Time |
1240-
+-------------+----------------------------+-----------------+
1241-
| d | 17/05/2016 | Short Date |
1242-
+-------------+----------------------------+-----------------+
1243-
| D | 17 May 2016 | Long Date |
1244-
+-------------+----------------------------+-----------------+
1245-
| f (default) | 17 May 2016 22:57 | Short Date Time |
1246-
+-------------+----------------------------+-----------------+
1247-
| F | Tuesday, 17 May 2016 22:57 | Long Date Time |
1248-
+-------------+----------------------------+-----------------+
1249-
| R | 5 years ago | Relative Time |
1250-
+-------------+----------------------------+-----------------+
1234+
+-------------+--------------------------------+-------------------------+
1235+
| Style | Example Output | Description |
1236+
+=============+================================+=========================+
1237+
| t | 22:57 | Short Time |
1238+
+-------------+--------------------------------+-------------------------+
1239+
| T | 22:57:58 | Medium Time |
1240+
+-------------+--------------------------------+-------------------------+
1241+
| d | 17/05/2016 | Short Date |
1242+
+-------------+--------------------------------+-------------------------+
1243+
| D | May 17, 2016 | Long Date |
1244+
+-------------+--------------------------------+-------------------------+
1245+
| f (default) | May 17, 2016 at 22:57 | Long Date, Short Time |
1246+
+-------------+--------------------------------+-------------------------+
1247+
| F | Tuesday, May 17, 2016 at 22:57 | Full Date, Short Time |
1248+
+-------------+--------------------------------+-------------------------+
1249+
| s | 17/05/2016, 22:57 | Short Date, Short Time |
1250+
+-------------+--------------------------------+-------------------------+
1251+
| S | 17/05/2016, 22:57:58 | Short Date, Medium Time |
1252+
+-------------+--------------------------------+-------------------------+
1253+
| R | 5 years ago | Relative Time |
1254+
+-------------+--------------------------------+-------------------------+
12511255
12521256
Note that the exact output depends on the user's locale setting in the client. The example output
12531257
presented is using the ``en-GB`` locale.

0 commit comments

Comments
 (0)