Format an ISO date/datetime for display, keeping the ISO value for submission.
(isoValue: string, schema: PrimitiveSchemaDefinition)
| 78 | |
| 79 | /** Format an ISO date/datetime for display, keeping the ISO value for submission. */ |
| 80 | function formatDateDisplay(isoValue: string, schema: PrimitiveSchemaDefinition): string { |
| 81 | try { |
| 82 | const date = new Date(isoValue); |
| 83 | if (Number.isNaN(date.getTime())) return isoValue; |
| 84 | const format = 'format' in schema ? schema.format : undefined; |
| 85 | if (format === 'date-time') { |
| 86 | return date.toLocaleDateString('en-US', { |
| 87 | weekday: 'short', |
| 88 | year: 'numeric', |
| 89 | month: 'short', |
| 90 | day: 'numeric', |
| 91 | hour: 'numeric', |
| 92 | minute: '2-digit', |
| 93 | timeZoneName: 'short' |
| 94 | }); |
| 95 | } |
| 96 | // date-only: parse as local date to avoid timezone shift |
| 97 | const parts = isoValue.split('-'); |
| 98 | if (parts.length === 3) { |
| 99 | const local = new Date(Number(parts[0]), Number(parts[1]) - 1, Number(parts[2])); |
| 100 | return local.toLocaleDateString('en-US', { |
| 101 | weekday: 'short', |
| 102 | year: 'numeric', |
| 103 | month: 'short', |
| 104 | day: 'numeric' |
| 105 | }); |
| 106 | } |
| 107 | return isoValue; |
| 108 | } catch { |
| 109 | return isoValue; |
| 110 | } |
| 111 | } |
| 112 | export function ElicitationDialog(t0) { |
| 113 | const $ = _c(7); |
| 114 | const { |