ErrorBoundary
1 year ago
Icons
9 months ago
Notifications
11 months ago
Tabs
9 months ago
store
1 year ago
AdminDetailsPage.module.scss
9 months ago
AdminSection.tsx
1 year ago
ConfirmationDialog.tsx
9 months ago
DefaultPrimaryActionButton.tsx
1 year ago
index.tsx
9 months ago
types.ts
9 months ago
utils.ts
9 months ago
utils.ts
45 lines
| 1 | /** |
| 2 | * @since 4.4.0 |
| 3 | */ |
| 4 | export function amountFormatter(currency: Intl.NumberFormatOptions['currency'], options?: Intl.NumberFormatOptions): Intl.NumberFormat { |
| 5 | return new Intl.NumberFormat(navigator.language, { |
| 6 | style: 'currency', |
| 7 | currency: currency, |
| 8 | ...options |
| 9 | }); |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * @since 4.6.0 |
| 14 | */ |
| 15 | export function formatDateTimeLocal(dateString: string) { |
| 16 | if (!dateString) return ''; |
| 17 | |
| 18 | const date = new Date(dateString); |
| 19 | if (isNaN(date.getTime())) return ''; |
| 20 | |
| 21 | const year = date.getFullYear(); |
| 22 | const month = String(date.getMonth() + 1).padStart(2, '0'); |
| 23 | const day = String(date.getDate()).padStart(2, '0'); |
| 24 | const hours = String(date.getHours()).padStart(2, '0'); |
| 25 | const minutes = String(date.getMinutes()).padStart(2, '0'); |
| 26 | |
| 27 | return `${year}-${month}-${day}T${hours}:${minutes}:00`; |
| 28 | } |
| 29 | |
| 30 | |
| 31 | /** |
| 32 | * @since 4.8.0 |
| 33 | */ |
| 34 | export function formatDateLocal(dateString: string) { |
| 35 | if (!dateString) return ''; |
| 36 | |
| 37 | const date = new Date(dateString); |
| 38 | |
| 39 | const year = date.getFullYear(); |
| 40 | const month = String(date.getMonth() + 1).padStart(2, '0'); |
| 41 | const day = String(date.getDate()).padStart(2, '0'); |
| 42 | |
| 43 | return `${year}-${month}-${day}`; |
| 44 | } |
| 45 |