Browse Source

Document new timestamp format style

pull/10347/head
Sacul 8 months ago
committed by GitHub
parent
commit
0ace5f8b51
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 40
      discord/utils.py

40
discord/utils.py

@ -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 |
+-------------+----------------------------+-----------------+ +-------------+--------------------------------+-------------------------+
| R | 5 years ago | Relative 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 |
+-------------+--------------------------------+-------------------------+
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.

Loading…
Cancel
Save