@@ -6,20 +6,20 @@ type t = Js.Date.t
6
6
type time = float
7
7
8
8
/**
9
- A type representing date time format options.
10
-
11
- Note: There are some properties missing:
12
- - fractionalSecondDigits
13
- - dayPeriod
14
- - calendar
15
- - numberingSystem
16
- - localeMatcher
17
- - timeZone
18
- - hour12
19
- - hourCycle
20
- - formatMatcher
21
-
22
- See full spec at https://tc39.es/ecma402/#datetimeformat-objects
9
+ A type representing date time format options.
10
+
11
+ Note: There are some properties missing:
12
+ - fractionalSecondDigits
13
+ - dayPeriod
14
+ - calendar
15
+ - numberingSystem
16
+ - localeMatcher
17
+ - timeZone
18
+ - hour12
19
+ - hourCycle
20
+ - formatMatcher
21
+
22
+ See full spec at https://tc39.es/ecma402/#datetimeformat-objects
23
23
*/
24
24
type localeOptions = {
25
25
dateStyle ?: [#full | #long | #medium | #short ],
@@ -167,123 +167,140 @@ external setUTCMinutesSMs: (t, ~minutes: int, ~seconds: int, ~milliseconds: int)
167
167
@send external toTimeString : t => string = "toTimeString"
168
168
169
169
/**
170
- `toLocaleDateString(date)`
170
+ `toLocaleDateString(date)`
171
171
172
- Converts a JavaScript date to a localized date string. It will use the current locale.
172
+ Converts a JavaScript date to a localized date string. It will use the current locale.
173
173
174
- ## Examples
175
- ```rescript
176
- Date.make()->Date.toLocaleDateString->Console.log
177
- ```
174
+ ## Examples
175
+ ```rescript
176
+ Date.make()->Date.toLocaleDateString->Console.log
177
+ // 2/19/2023
178
+ ```
178
179
*/
179
180
@send
180
181
external toLocaleDateString : t => string = "toLocaleDateString"
181
182
182
183
/**
183
- `toLocaleDateStringWithLocale(date, locale)`
184
+ `toLocaleDateStringWithLocale(date, locale)`
184
185
185
- Converts a JavaScript date to a localized date string. It will use the specified locale.
186
+ Converts a JavaScript date to a localized date string. It will use the specified locale.
186
187
187
- ## Examples
188
- ```rescript
189
- Date.make()->Date.toLocaleDateStringWithLocale("en-US")->Console.log
190
- ```
188
+ ## Examples
189
+ ```rescript
190
+ Date.make()->Date.toLocaleDateStringWithLocale("en-US")->Console.log
191
+ // 2/19/2023
192
+ ```
191
193
*/
192
194
@send
193
195
external toLocaleDateStringWithLocale : (t , string ) => string = "toLocaleDateString"
194
196
195
197
/**
196
- `toLocaleDateStringWithLocaleAndOptions(date, locale, options)`
198
+ `toLocaleDateStringWithLocaleAndOptions(date, locale, options)`
197
199
198
- Converts a JavaScript date to a localized date string. It will use the specified locale and formatting options.
200
+ Converts a JavaScript date to a localized date string. It will use the specified locale and formatting options.
199
201
200
- ## Examples
201
- ```rescript
202
- Date.make()->Date.toLocaleDateStringWithLocaleAndOptions("en-US", { dateStyle: #long })->Console.log
203
- Date.make()->Date.toLocaleDateStringWithLocaleAndOptions("de", { hour: #"2-digit", minute: #"2-digit" })->Console.log
204
- Date.make()->Date.toLocaleDateStringWithLocaleAndOptions("de", { year: #numeric })->Console.log
205
- ```
202
+ ## Examples
203
+ ```rescript
204
+ Date.make()->Date.toLocaleDateStringWithLocaleAndOptions("en-US", { dateStyle: #long })->Console.log
205
+ // February 19, 2023
206
+
207
+ Date.make()->Date.toLocaleDateStringWithLocaleAndOptions("de", { hour: #"2-digit", minute: #"2-digit" })->Console.log
208
+ // 19.2.2023, 15:40
209
+
210
+ Date.make()->Date.toLocaleDateStringWithLocaleAndOptions("de", { year: #numeric })->Console.log
211
+ // 2023
212
+ ```
206
213
*/
207
214
@send
208
215
external toLocaleDateStringWithLocaleAndOptions : (t , string , localeOptions ) => string =
209
216
"toLocaleDateString"
210
217
211
218
/**
212
- `toLocaleString(date)`
219
+ `toLocaleString(date)`
213
220
214
- Converts a JavaScript date to a localized date-time string. It will use the current locale.
221
+ Converts a JavaScript date to a localized date-time string. It will use the current locale.
215
222
216
- ## Examples
217
- ```rescript
218
- Date.make()->Date.toLocaleString->Console.log
219
- ```
223
+ ## Examples
224
+ ```rescript
225
+ Date.make()->Date.toLocaleString->Console.log
226
+ // 2/19/2023, 3:40:00 PM
227
+ ```
220
228
*/
221
229
@send
222
230
external toLocaleString : t => string = "toLocaleString"
223
231
224
232
/**
225
- `toLocaleStringWithLocale(date, locale)`
233
+ `toLocaleStringWithLocale(date, locale)`
226
234
227
- Converts a JavaScript date to a localized date-time string. It will use the specified locale.
235
+ Converts a JavaScript date to a localized date-time string. It will use the specified locale.
228
236
229
- ## Examples
230
- ```rescript
231
- Date.make()->Date.toLocaleStringWithLocale("en-US")->Console.log
232
- ```
237
+ ## Examples
238
+ ```rescript
239
+ Date.make()->Date.toLocaleStringWithLocale("en-US")->Console.log
240
+ // 2/19/2023, 3:40:00 PM
241
+ ```
233
242
*/
234
243
@send
235
244
external toLocaleStringWithLocale : (t , string ) => string = "toLocaleString"
236
245
237
246
/**
238
- `toLocaleStringWithLocaleAndOptions(date, locale, options)`
247
+ `toLocaleStringWithLocaleAndOptions(date, locale, options)`
239
248
240
- Converts a JavaScript date to a localized date-time string. It will use the specified locale and formatting options.
249
+ Converts a JavaScript date to a localized date-time string. It will use the specified locale and formatting options.
241
250
242
- ## Examples
243
- ```rescript
244
- Date.make()->Date.toLocaleStringWithLocaleAndOptions("en", { dateStyle: #short, timeStyle: #short })->Console.log
245
- Date.make()->Date.toLocaleStringWithLocaleAndOptions("en", { era: #long, year: #numeric, month: #"2-digit", day: #"2-digit", hour: #numeric, timeZoneName: #short })->Console.log
246
- ```
251
+ ## Examples
252
+ ```rescript
253
+ Date.make()->Date.toLocaleStringWithLocaleAndOptions("en", { dateStyle: #short, timeStyle: #short })->Console.log
254
+ // 2/19/23, 3:40 PM
255
+
256
+ Date.make()->Date.toLocaleStringWithLocaleAndOptions("en", { era: #long, year: #numeric, month: #"2-digit", day: #"2-digit", hour: #numeric, timeZoneName: #short })->Console.log
257
+ // 02/19/2023 Anno Domini, 3 PM GMT+1
258
+ ```
247
259
*/
248
260
@send
249
261
external toLocaleStringWithLocaleAndOptions : (t , string , localeOptions ) => string = "toLocaleString"
250
262
251
263
/**
252
- `toLocaleTimeString(date)`
264
+ `toLocaleTimeString(date)`
253
265
254
- Converts a JavaScript date to a localized time string. It will use the current locale.
266
+ Converts a JavaScript date to a localized time string. It will use the current locale.
255
267
256
- ## Examples
257
- ```rescript
258
- Date.make()->Date.toLocaleTimeString->Console.log
259
- ```
268
+ ## Examples
269
+ ```rescript
270
+ Date.make()->Date.toLocaleTimeString->Console.log
271
+ // 3:40:00 PM
272
+ ```
260
273
*/
261
274
@send
262
275
external toLocaleTimeString : t => string = "toLocaleTimeString"
263
276
264
277
/**
265
- `toLocaleTimeStringWithLocale(date, locale)`
278
+ `toLocaleTimeStringWithLocale(date, locale)`
266
279
267
- Converts a JavaScript date to a localized time string. It will use the specified locale.
280
+ Converts a JavaScript date to a localized time string. It will use the specified locale.
268
281
269
- ## Examples
270
- ```rescript
271
- Date.make()->Date.toLocaleTimeStringWithLocale("en-US")->Console.log
272
- ```
282
+ ## Examples
283
+ ```rescript
284
+ Date.make()->Date.toLocaleTimeStringWithLocale("en-US")->Console.log
285
+ // 3:40:00 PM
286
+ ```
273
287
*/
274
288
@send
275
289
external toLocaleTimeStringWithLocale : (t , string ) => string = "toLocaleTimeString"
276
290
277
291
/**
278
- `toLocaleTimeStringWithLocaleAndOptions(date, locale, options)`
292
+ `toLocaleTimeStringWithLocaleAndOptions(date, locale, options)`
293
+
294
+ Converts a JavaScript date to a localized time string. It will use the specified locale and formatting options.
279
295
280
- Converts a JavaScript date to a localized time string. It will use the specified locale and formatting options.
296
+ ## Examples
297
+ ```rescript
298
+ Date.make()->Date.toLocaleTimeStringWithLocaleAndOptions("en-US", { timeStyle: #long })->Console.log
299
+ // 3:40:00 PM GMT+1
281
300
282
- ## Examples
283
- ```rescript
284
- Date.make()->Date.toLocaleTimeStringWithLocaleAndOptions("en-US", { timeStyle: #long })->Console.log
285
- Date.make()->Date.toLocaleTimeStringWithLocaleAndOptions("de", { hour: #"2-digit", minute: #"2-digit" })->Console.log
286
- ```
301
+ Date.make()->Date.toLocaleTimeStringWithLocaleAndOptions("de", { hour: #"2-digit", minute: #"2-digit" })->Console.log
302
+ // 15:40
303
+ ```
287
304
*/
288
305
@send
289
306
external toLocaleTimeStringWithLocaleAndOptions : (t , string , localeOptions ) => string =
0 commit comments