From 0ace5f8b51f8906d8bd99eaf17095ff4f11be4dd Mon Sep 17 00:00:00 2001 From: Sacul <183588943+Sacul0457@users.noreply.github.com> Date: Sat, 8 Nov 2025 07:56:24 +0800 Subject: [PATCH] Document new timestamp format style --- discord/utils.py | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/discord/utils.py b/discord/utils.py index 986d166d3..e2bc96bb1 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -1223,7 +1223,7 @@ def is_inside_class(func: Callable[..., Any]) -> bool: return not remaining.endswith('') -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: @@ -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. - +-------------+----------------------------+-----------------+ - | Style | Example Output | Description | - +=============+============================+=================+ - | t | 22:57 | Short Time | - +-------------+----------------------------+-----------------+ - | T | 22:57:58 | Long Time | - +-------------+----------------------------+-----------------+ - | d | 17/05/2016 | Short Date | - +-------------+----------------------------+-----------------+ - | D | 17 May 2016 | Long Date | - +-------------+----------------------------+-----------------+ - | f (default) | 17 May 2016 22:57 | Short Date Time | - +-------------+----------------------------+-----------------+ - | F | Tuesday, 17 May 2016 22:57 | Long Date Time | - +-------------+----------------------------+-----------------+ - | R | 5 years ago | Relative Time | - +-------------+----------------------------+-----------------+ + +-------------+--------------------------------+-------------------------+ + | Style | Example Output | Description | + +=============+================================+=========================+ + | t | 22:57 | Short Time | + +-------------+--------------------------------+-------------------------+ + | T | 22:57:58 | Medium Time | + +-------------+--------------------------------+-------------------------+ + | d | 17/05/2016 | Short Date | + +-------------+--------------------------------+-------------------------+ + | D | May 17, 2016 | Long Date | + +-------------+--------------------------------+-------------------------+ + | f (default) | May 17, 2016 at 22:57 | Long Date, Short 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 | + +-------------+--------------------------------+-------------------------+ 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.