Skip to content

Commit 943bc54

Browse files
committed
Add locale and formatting options to localeDateString, localeString and localTimeString functions
1 parent 7947146 commit 943bc54

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/Core__Date.res

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ type t = Js.Date.t
22

33
type time = float
44

5+
type localeOptions = {
6+
dateStyle?: [#full | #long | #medium | #short],
7+
timeStyle?: [#full | #long | #medium | #short],
8+
weekday?: [#long | #short | #narrow],
9+
era?: [#long | #short | #narrow],
10+
year?: [#numeric | #"2-digit"],
11+
month?: [#numeric | #"2-digit" | #long | #short | #narrow],
12+
day?: [#numeric | #"2-digit"],
13+
hour?: [#numeric | #"2-digit"],
14+
minute?: [#numeric | #"2-digit"],
15+
second?: [#numeric | #"2-digit"],
16+
timeZoneName?: [#long | #short],
17+
}
18+
519
@send external valueOf: t => time = "valueOf"
620

721
@new external make: unit => t = "Date"
@@ -146,8 +160,19 @@ external setUTCMinutesSMs: (t, ~minutes: int, ~seconds: int, ~milliseconds: int)
146160
@send external toTimeString: t => string = "toTimeString"
147161

148162
@send external toLocaleDateString: t => string = "toLocaleDateString"
163+
@send external toLocaleDateStringWithLocale: (t, string) => string = "toLocaleDateString"
164+
@send
165+
external toLocaleDateStringWithLocaleAndOptions: (t, string, localeOptions) => string =
166+
"toLocaleDateString"
149167
@send external toLocaleString: t => string = "toLocaleString"
168+
@send external toLocaleStringWithLocale: (t, string) => string = "toLocaleString"
169+
@send
170+
external toLocaleStringWithLocaleAndOptions: (t, string, localeOptions) => string = "toLocaleString"
150171
@send external toLocaleTimeString: t => string = "toLocaleTimeString"
172+
@send external toLocaleTimeStringWithLocale: (t, string) => string = "toLocaleTimeString"
173+
@send
174+
external toLocaleTimeStringWithLocaleAndOptions: (t, string, localeOptions) => string =
175+
"toLocaleTimeString"
151176

152177
@send external toISOString: t => string = "toISOString"
153178
@send external toUTCString: t => string = "toUTCString"

0 commit comments

Comments
 (0)