feat!: support new s/S timestamp styles (#11267)

BREAKING CHANGE: `TimestampStyles.LongTime` has been removed. Use `TimestampStyles.MediumTime` instead.
BREAKING CHANGE: `TimestampStyles.ShortDateTime` has been removed. Use `TimestampStyles.LongDateShortTime` instead.
BREAKING CHANGE: `TimestampStyles.LongDateTime` has been removed. Use `TimestampStyles.FullDateShortTime` instead.
This commit is contained in:
Danial Raza
2025-11-12 11:55:20 +01:00
committed by GitHub
parent 538b47dd00
commit e8217e335c
2 changed files with 35 additions and 11 deletions

View File

@@ -331,8 +331,18 @@ describe('Message formatters', () => {
expect<'<t:1867424897:d>'>(time(1_867_424_897, 'd')).toEqual('<t:1867424897:d>'); expect<'<t:1867424897:d>'>(time(1_867_424_897, 'd')).toEqual('<t:1867424897:d>');
}); });
test('GIVEN a date and a format from enum THEN returns "<t:${time}:${style}>"', () => { test.each([
expect<'<t:1867424897:R>'>(time(1_867_424_897, TimestampStyles.RelativeTime)).toEqual('<t:1867424897:R>'); [TimestampStyles.ShortTime, 't'],
[TimestampStyles.MediumTime, 'T'],
[TimestampStyles.ShortDate, 'd'],
[TimestampStyles.LongDate, 'D'],
[TimestampStyles.LongDateShortTime, 'f'],
[TimestampStyles.FullDateShortTime, 'F'],
[TimestampStyles.ShortDateShortTime, 's'],
[TimestampStyles.ShortDateMediumTime, 'S'],
[TimestampStyles.RelativeTime, 'R'],
])('GIVEN a date and style from enum THEN returns "<t:${time}:${style}>"', (style, expectedStyle) => {
expect<`<t:1867424897:${typeof style}>`>(time(1_867_424_897, style)).toEqual(`<t:1867424897:${expectedStyle}>`);
}); });
}); });

View File

@@ -725,11 +725,11 @@ export const TimestampStyles = {
ShortTime: 't', ShortTime: 't',
/** /**
* Long time format, consisting of hours, minutes, and seconds. * Medium time format, consisting of hours, minutes, and seconds.
* *
* @example `16:20:30` * @example `16:20:30`
*/ */
LongTime: 'T', MediumTime: 'T',
/** /**
* Short date format, consisting of day, month, and year. * Short date format, consisting of day, month, and year.
@@ -741,23 +741,37 @@ export const TimestampStyles = {
/** /**
* Long date format, consisting of day, month, and year. * Long date format, consisting of day, month, and year.
* *
* @example `20 April 2021` * @example `April 20, 2021`
*/ */
LongDate: 'D', LongDate: 'D',
/** /**
* Short date-time format, consisting of short date and short time formats. * Long date-short time format, consisting of long date and short time.
* *
* @example `20 April 2021 16:20` * @example `April 20, 2021 at 16:20`
*/ */
ShortDateTime: 'f', LongDateShortTime: 'f',
/** /**
* Long date-time format, consisting of long date and short time formats. * Full date-short time format, consisting of full date and short time.
* *
* @example `Tuesday, 20 April 2021 16:20` * @example `Tuesday, April 20, 2021 at 16:20`
*/ */
LongDateTime: 'F', FullDateShortTime: 'F',
/**
* Short date, short time format, consisting of short date and short time.
*
* @example `20/04/2021, 16:20`
*/
ShortDateShortTime: 's',
/**
* Short date, medium time format, consisting of short date and medium time.
*
* @example `20/04/2021, 16:20:30`
*/
ShortDateMediumTime: 'S',
/** /**
* Relative time format, consisting of a relative duration format. * Relative time format, consisting of a relative duration format.