(
date: FormatParameters[0],
formatString: FormatInTimezoneParameters[1],
timezone: FormatInTimezoneParameters[2] = Intl.DateTimeFormat().resolvedOptions()
.timeZone,
options?: FormatInTimezoneParameters[3],
)
| 39 | * This function should be used instead of date-fns' `format`. |
| 40 | */ |
| 41 | export function formatDate( |
| 42 | date: FormatParameters[0], |
| 43 | formatString: FormatInTimezoneParameters[1], |
| 44 | timezone: FormatInTimezoneParameters[2] = Intl.DateTimeFormat().resolvedOptions() |
| 45 | .timeZone, |
| 46 | options?: FormatInTimezoneParameters[3], |
| 47 | ) { |
| 48 | try { |
| 49 | const formattedString = formatInTimeZone( |
| 50 | date, |
| 51 | timezone, |
| 52 | formatString, |
| 53 | options, |
| 54 | ); |
| 55 | return formattedString; |
| 56 | } catch { |
| 57 | return format(date, formatString, options); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | export function formatDateInUtc( |
| 62 | timestampOrDate: number | Date, |
no outgoing calls
no test coverage detected