Document new timestamp format style

This commit is contained in:
Sacul
2025-11-08 07:56:24 +08:00
committed by GitHub
parent e2cf721e9c
commit 0ace5f8b51

View File

@@ -1223,7 +1223,7 @@ def is_inside_class(func: Callable[..., Any]) -> bool:
return not remaining.endswith('<locals>') return not remaining.endswith('<locals>')
TimestampStyle = Literal['f', 'F', 'd', 'D', 't', 'T', 'R'] TimestampStyle = Literal['f', 'F', 'd', 'D', 't', 'T', 's', 'S', 'R']
def format_dt(dt: datetime.datetime, /, style: Optional[TimestampStyle] = None) -> str: def format_dt(dt: datetime.datetime, /, style: Optional[TimestampStyle] = None) -> str:
@@ -1231,23 +1231,27 @@ def format_dt(dt: datetime.datetime, /, style: Optional[TimestampStyle] = None)
This allows for a locale-independent way of presenting data using Discord specific Markdown. This allows for a locale-independent way of presenting data using Discord specific Markdown.
+-------------+----------------------------+-----------------+ +-------------+--------------------------------+-------------------------+
| Style | Example Output | Description | | Style | Example Output | Description |
+=============+============================+=================+ +=============+================================+=========================+
| t | 22:57 | Short Time | | t | 22:57 | Short Time |
+-------------+----------------------------+-----------------+ +-------------+--------------------------------+-------------------------+
| T | 22:57:58 | Long Time | | T | 22:57:58 | Medium Time |
+-------------+----------------------------+-----------------+ +-------------+--------------------------------+-------------------------+
| d | 17/05/2016 | Short Date | | d | 17/05/2016 | Short Date |
+-------------+----------------------------+-----------------+ +-------------+--------------------------------+-------------------------+
| D | 17 May 2016 | Long Date | | D | May 17, 2016 | Long Date |
+-------------+----------------------------+-----------------+ +-------------+--------------------------------+-------------------------+
| f (default) | 17 May 2016 22:57 | Short Date Time | | f (default) | May 17, 2016 at 22:57 | Long Date, Short Time |
+-------------+----------------------------+-----------------+ +-------------+--------------------------------+-------------------------+
| F | Tuesday, 17 May 2016 22:57 | Long Date Time | | F | Tuesday, May 17, 2016 at 22:57 | Full Date, Short Time |
+-------------+----------------------------+-----------------+ +-------------+--------------------------------+-------------------------+
| s | 17/05/2016, 22:57 | Short Date, Short Time |
+-------------+--------------------------------+-------------------------+
| S | 17/05/2016, 22:57:58 | Short Date, Medium Time |
+-------------+--------------------------------+-------------------------+
| R | 5 years ago | Relative Time | | R | 5 years ago | Relative Time |
+-------------+----------------------------+-----------------+ +-------------+--------------------------------+-------------------------+
Note that the exact output depends on the user's locale setting in the client. The example output Note that the exact output depends on the user's locale setting in the client. The example output
presented is using the ``en-GB`` locale. presented is using the ``en-GB`` locale.