1 import { formatIntlDate } from '../date/formatIntlDate';
2 import { fromUTCDate, toLocalDate } from '../date/timezone';
3 import { localeCode } from '../i18n';
6 * Format UTC date with Intl.DateTimeFormat
7 * @param date date to be formatted
8 * @param options formatting options, e.g. { weekday: 'short', month: 'long', year: 'numeric', timeStyle: 'short' }
9 * @param locale [Optional] locale to be used when formatting. Defaults to the app locale
11 export const formatIntlUTCDate = (date: Date, options: Intl.DateTimeFormatOptions, locale = localeCode) => {
12 // Use fake local date built from the UTC date data
13 const localDate = toLocalDate(fromUTCDate(date));
15 return formatIntlDate(localDate, options, locale);