-
Notifications
You must be signed in to change notification settings - Fork 4
Function.resolveDateTimeFormat
connor-baer edited this page Dec 5, 2024
·
56 revisions
@sumup-oss/intl / resolveDateTimeFormat
resolveDateTimeFormat(
locales
?,options
?):null
|ResolvedDateTimeFormatOptions
Resolves the locale and collation options that are used to format a Date
.
Parameter | Type |
---|---|
locales ? |
string | string [] |
options ? |
DateTimeFormatOptions |
null
| ResolvedDateTimeFormatOptions
import { resolveDateTimeFormat } from '@sumup-oss/intl';
resolveDateTimeFormat();
// {
// 'locale': 'en-DE',
// 'calendar': 'gregory',
// 'numberingSystem': 'latn',
// 'timeZone': 'Europe/Berlin',
// 'year': 'numeric',
// 'month': '2-digit',
// 'day': '2-digit'
// }
resolveDateTimeFormat(['ban', 'id']);
// {
// 'locale': 'id',
// 'calendar': 'gregory',
// 'numberingSystem': 'latn',
// 'timeZone': 'Europe/Berlin',
// 'year': 'numeric',
// 'month': 'numeric',
// 'day': 'numeric'
// }
resolveDateTimeFormat('en-GB', {
year: 'numeric',
month: 'short',
day: 'numeric',
});
// {
// 'locale': 'en-GB',
// 'calendar': 'gregory',
// 'numberingSystem': 'latn',
// 'timeZone': 'Europe/Berlin',
// 'year': 'numeric',
// 'month': 'short',
// 'day': 'numeric'
// }
In runtimes that don't support the Intl.DateTimeFormat.resolvedOptions
API,
null
is returned.