|
1 | 1 | type t
|
2 | 2 |
|
| 3 | +type dateStyle = [#full | #long | #medium | #short] |
| 4 | +type timeStyle = [#full | #long | #medium | #short] |
| 5 | +type calendar = [ |
| 6 | + | #buddhist |
| 7 | + | #chinese |
| 8 | + | #coptic |
| 9 | + | #dangi |
| 10 | + | #ethioaa |
| 11 | + | #ethiopic |
| 12 | + | #gregory |
| 13 | + | #hebrew |
| 14 | + | #indian |
| 15 | + | #islamic |
| 16 | + | #"islamic-umalqura" |
| 17 | + | #"islamic-tbla" |
| 18 | + | #"islamic-civil" |
| 19 | + | #"islamic-rgsa" |
| 20 | + | #iso8601 |
| 21 | + | #japanese |
| 22 | + | #persian |
| 23 | + | #roc |
| 24 | +] |
| 25 | +type dayPeriod = [#narrow | #short | #long] |
| 26 | +type weekday = [#narrow | #short | #long] |
| 27 | +type era = [#narrow | #short | #long] |
| 28 | +type year = [#numeric | #"2-digit"] |
| 29 | +type month = [#numeric | #"2-digit" | #narrow | #short | #long] |
| 30 | +type day = [#numeric | #"2-digit"] |
| 31 | +type hour = [#numeric | #"2-digit"] |
| 32 | +type minute = [#numeric | #"2-digit"] |
| 33 | +type second = [#numeric | #"2-digit"] |
| 34 | +// Firefox also supports IANA time zone names here |
| 35 | +type timeZoneName = [ |
| 36 | + | #short |
| 37 | + | #long |
| 38 | +] |
| 39 | +// TODO unsupported in node? |
| 40 | +// | #shortOffset |
| 41 | +// | #shortGeneric |
| 42 | +// | #longOffset |
| 43 | +// | #longGeneric |
| 44 | + |
| 45 | +type hourCycle = [#h11 | #h12 | #h23 | #h24] |
| 46 | +type formatMatcher = [#basic | @as("best fit") #bestFit] |
| 47 | +type fractionalSecondDigits = [#0 | #1 | #2 | #3] |
| 48 | + |
| 49 | +type options = { |
| 50 | + dateStyle?: dateStyle, // can be used with timeStyle, but not other options |
| 51 | + timeStyle?: timeStyle, // can be used with dateStyle, but not other options |
| 52 | + calendar?: calendar, |
| 53 | + dayPeriod?: dayPeriod, // only has an effect if a 12-hour clock is used |
| 54 | + numberingSystem?: Core__Intl__Common.numberingSystem, |
| 55 | + localeMatcher?: Core__Intl__Common.localeMatcher, |
| 56 | + timeZone?: string, |
| 57 | + hour12?: bool, |
| 58 | + hourCycle?: hourCycle, |
| 59 | + formatMatcher?: formatMatcher, |
| 60 | + // date-time components |
| 61 | + weekday?: weekday, |
| 62 | + era?: era, |
| 63 | + year?: year, |
| 64 | + month?: month, |
| 65 | + day?: day, |
| 66 | + hour?: hour, |
| 67 | + minute?: minute, |
| 68 | + second?: second, |
| 69 | + fractionalSecondDigits?: fractionalSecondDigits, |
| 70 | + timeZoneName?: timeZoneName, |
| 71 | +} |
| 72 | + |
| 73 | +type resolvedOptions = { |
| 74 | + dateStyle?: dateStyle, |
| 75 | + timeStyle?: timeStyle, |
| 76 | + weekday?: weekday, |
| 77 | + era?: era, |
| 78 | + year?: year, |
| 79 | + month?: month, |
| 80 | + day?: day, |
| 81 | + hour?: hour, |
| 82 | + minute?: minute, |
| 83 | + second?: second, |
| 84 | + fractionalSecondDigits?: fractionalSecondDigits, |
| 85 | + timeZoneName?: timeZoneName, |
| 86 | + calendar: calendar, |
| 87 | + hour12: bool, |
| 88 | + hourCycle: hourCycle, |
| 89 | + locale: string, |
| 90 | + numberingSystem: Core__Intl__Common.numberingSystem, |
| 91 | + timeZone: string, |
| 92 | +} |
| 93 | + |
| 94 | +type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} |
| 95 | + |
| 96 | +type dateTimeComponent = [ |
| 97 | + | #day |
| 98 | + | #dayPeriod |
| 99 | + | #era |
| 100 | + | #fractionalSecond |
| 101 | + | #hour |
| 102 | + | #literal |
| 103 | + | #minute |
| 104 | + | #month |
| 105 | + | #relatedYear |
| 106 | + | #second |
| 107 | + | #timeZone |
| 108 | + | #weekday |
| 109 | + | #year |
| 110 | + | #yearName |
| 111 | +] |
| 112 | + |
| 113 | +type dateTimePart = { |
| 114 | + \"type": dateTimeComponent, |
| 115 | + value: string, |
| 116 | +} |
| 117 | + |
| 118 | +type dateTimeRangeSource = [#startRange | #shared | #endRange] |
| 119 | +type dateTimeRangePart = { |
| 120 | + \"type": dateTimeComponent, |
| 121 | + value: string, |
| 122 | + source: dateTimeRangeSource, |
| 123 | +} |
| 124 | + |
3 | 125 | @new external make: unit => t = "Intl.DateTimeFormat"
|
4 | 126 | @new external makeWithLocale: string => t = "Intl.DateTimeFormat"
|
5 | 127 | @new external makeWithLocales: array<string> => t = "Intl.DateTimeFormat"
|
6 |
| -@new external makeWithLocaleAndOptions: (string, {..}) => t = "Intl.DateTimeFormat" |
7 |
| -@new external makeWithLocalesAndOptions: (array<string>, {..}) => t = "Intl.DateTimeFormat" |
8 |
| -@new external makeWithOptions: (@as(json`undefined`) _, {..}) => t = "Intl.DateTimeFormat" |
| 128 | +@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.DateTimeFormat" |
| 129 | +@new external makeWithLocalesAndOptions: (array<string>, options) => t = "Intl.DateTimeFormat" |
| 130 | +@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.DateTimeFormat" |
9 | 131 |
|
10 | 132 | @val external supportedLocalesOf: array<string> => t = "Intl.DateTimeFormat.supportedLocalesOf"
|
11 | 133 | @val
|
12 |
| -external supportedLocalesOfWithOptions: (array<string>, {..}) => t = |
| 134 | +external supportedLocalesOfWithOptions: (array<string>, supportedLocalesOptions) => t = |
13 | 135 | "Intl.DateTimeFormat.supportedLocalesOf"
|
14 | 136 |
|
15 |
| -@send external resolvedOptions: t => {..} = "resolvedOptions" |
| 137 | +@send external resolvedOptions: t => resolvedOptions = "resolvedOptions" |
16 | 138 |
|
17 | 139 | @send external format: (t, Core__Date.t) => string = "format"
|
18 | 140 | @send
|
|
0 commit comments