Skip to content

Commit 40c51a5

Browse files
committed
replace ~date with ~day for Date.make*
1 parent db89ef2 commit 40c51a5

File tree

5 files changed

+69
-65
lines changed

5 files changed

+69
-65
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
- Add `Dict.has` and double `Dict.forEachWithKey`/`Dict.mapValues` performance. https://github.com/rescript-lang/rescript/pull/7316
1818
- Add popover attributes to JsxDOM.domProps. https://github.com/rescript-lang/rescript/pull/7317
1919

20+
#### :boom: Breaking Change
21+
22+
- Replace ~date with ~day in Date.make\*. https://github.com/rescript-lang/rescript/pull/7324
23+
2024
#### :house: Internal
2125

2226
- Clean up legacy tags handling. https://github.com/rescript-lang/rescript/pull/7309

runtime/Stdlib_Date.res

+12-12
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ type localeOptions = {
2121
@new external fromTime: msSinceEpoch => t = "Date"
2222

2323
@new external makeWithYM: (~year: int, ~month: int) => t = "Date"
24-
@new external makeWithYMD: (~year: int, ~month: int, ~date: int) => t = "Date"
25-
@new external makeWithYMDH: (~year: int, ~month: int, ~date: int, ~hours: int) => t = "Date"
24+
@new external makeWithYMD: (~year: int, ~month: int, ~day: int) => t = "Date"
25+
@new external makeWithYMDH: (~year: int, ~month: int, ~day: int, ~hours: int) => t = "Date"
2626
@new
27-
external makeWithYMDHM: (~year: int, ~month: int, ~date: int, ~hours: int, ~minutes: int) => t =
27+
external makeWithYMDHM: (~year: int, ~month: int, ~day: int, ~hours: int, ~minutes: int) => t =
2828
"Date"
2929
@new
3030
external makeWithYMDHMS: (
3131
~year: int,
3232
~month: int,
33-
~date: int,
33+
~day: int,
3434
~hours: int,
3535
~minutes: int,
3636
~seconds: int,
@@ -39,7 +39,7 @@ external makeWithYMDHMS: (
3939
external makeWithYMDHMSM: (
4040
~year: int,
4141
~month: int,
42-
~date: int,
42+
~day: int,
4343
~hours: int,
4444
~minutes: int,
4545
~seconds: int,
@@ -48,23 +48,23 @@ external makeWithYMDHMSM: (
4848

4949
module UTC = {
5050
@val external makeWithYM: (~year: int, ~month: int) => msSinceEpoch = "Date.UTC"
51-
@val external makeWithYMD: (~year: int, ~month: int, ~date: int) => msSinceEpoch = "Date.UTC"
51+
@val external makeWithYMD: (~year: int, ~month: int, ~day: int) => msSinceEpoch = "Date.UTC"
5252
@val
53-
external makeWithYMDH: (~year: int, ~month: int, ~date: int, ~hours: int) => msSinceEpoch =
53+
external makeWithYMDH: (~year: int, ~month: int, ~day: int, ~hours: int) => msSinceEpoch =
5454
"Date.UTC"
5555
@val
5656
external makeWithYMDHM: (
5757
~year: int,
5858
~month: int,
59-
~date: int,
59+
~day: int,
6060
~hours: int,
6161
~minutes: int,
6262
) => msSinceEpoch = "Date.UTC"
6363
@val
6464
external makeWithYMDHMS: (
6565
~year: int,
6666
~month: int,
67-
~date: int,
67+
~day: int,
6868
~hours: int,
6969
~minutes: int,
7070
~seconds: int,
@@ -73,7 +73,7 @@ module UTC = {
7373
external makeWithYMDHMSM: (
7474
~year: int,
7575
~month: int,
76-
~date: int,
76+
~day: int,
7777
~hours: int,
7878
~minutes: int,
7979
~seconds: int,
@@ -102,7 +102,7 @@ let compare = (a, b) => Stdlib_Float.compare(a->getTime, b->getTime)
102102

103103
@send external setFullYear: (t, int) => unit = "setFullYear"
104104
@send external setFullYearM: (t, ~year: int, ~month: int) => unit = "setFullYear"
105-
@send external setFullYearMD: (t, ~year: int, ~month: int, ~date: int) => unit = "setFullYear"
105+
@send external setFullYearMD: (t, ~year: int, ~month: int, ~day: int) => unit = "setFullYear"
106106
@send external setMonth: (t, int) => unit = "setMonth"
107107
@send external setDate: (t, int) => unit = "setDate"
108108
@send external setHours: (t, int) => unit = "setHours"
@@ -132,7 +132,7 @@ external setMinutesSMs: (t, ~minutes: int, ~seconds: int, ~milliseconds: int) =>
132132
@send external setUTCFullYear: (t, int) => unit = "setUTCFullYear"
133133
@send external setUTCFullYearM: (t, ~year: int, ~month: int) => unit = "setUTCFullYear"
134134
@send
135-
external setUTCFullYearMD: (t, ~year: int, ~month: int, ~date: int) => unit = "setUTCFullYear"
135+
external setUTCFullYearMD: (t, ~year: int, ~month: int, ~day: int) => unit = "setUTCFullYear"
136136
@send external setUTCMonth: (t, int) => unit = "setUTCMonth"
137137
@send external setUTCDate: (t, int) => unit = "setUTCDate"
138138
@send external setUTCHours: (t, int) => unit = "setUTCHours"

runtime/Stdlib_Date.resi

+46-46
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,18 @@ Values, which are out of range, will be carried over to the next bigger unit (s.
138138

139139
## Examples
140140
```rescript
141-
Date.makeWithYMD(~year=2023, ~month=1, ~date=20)
141+
Date.makeWithYMD(~year=2023, ~month=1, ~day=20)
142142
// 2023-02-20T00:00:00.000Z
143143

144-
Date.makeWithYMD(~year=2023, ~month=1, ~date=-1)
144+
Date.makeWithYMD(~year=2023, ~month=1, ~day=-1)
145145
// 2022-11-29T00:00:00.000Z
146146

147-
Date.makeWithYMD(~year=2023, ~month=1, ~date=29)
147+
Date.makeWithYMD(~year=2023, ~month=1, ~day=29)
148148
// 2023-03-01T00:00:00.000Z
149149
```
150150
*/
151151
@new
152-
external makeWithYMD: (~year: int, ~month: int, ~date: int) => t = "Date"
152+
external makeWithYMD: (~year: int, ~month: int, ~day: int) => t = "Date"
153153

154154
/**
155155
Creates a date object with the given year, month, date (day of month) and hours.
@@ -159,13 +159,13 @@ Values, which are out of range, will be carried over to the next bigger unit (s.
159159

160160
## Examples
161161
```rescript
162-
Date.makeWithYMDH(~year=2023, ~month=1, ~date=20, ~hours=16)
162+
Date.makeWithYMDH(~year=2023, ~month=1, ~day=20, ~hours=16)
163163
// 2023-02-20T16:00:00.000Z
164164

165-
Date.makeWithYMDH(~year=2023, ~month=1, ~date=20, ~hours=24)
165+
Date.makeWithYMDH(~year=2023, ~month=1, ~day=20, ~hours=24)
166166
// 2023-02-21T00:00:00.000Z
167167

168-
Date.makeWithYMDH(~year=2023, ~month=1, ~date=20, ~hours=-1)
168+
Date.makeWithYMDH(~year=2023, ~month=1, ~day=20, ~hours=-1)
169169
// 2023-02-19T23:00:00.000Z
170170

171171
// Note: The output depends on your local time zone.
@@ -174,7 +174,7 @@ Date.makeWithYMDH(~year=2023, ~month=1, ~date=20, ~hours=-1)
174174
```
175175
*/
176176
@new
177-
external makeWithYMDH: (~year: int, ~month: int, ~date: int, ~hours: int) => t = "Date"
177+
external makeWithYMDH: (~year: int, ~month: int, ~day: int, ~hours: int) => t = "Date"
178178

179179
/**
180180
Creates a date object with the given year, month, date (day of month), hours and minutes.
@@ -184,13 +184,13 @@ Values, which are out of range, will be carried over to the next bigger unit (s.
184184

185185
## Examples
186186
```rescript
187-
Date.makeWithYMDHM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40)
187+
Date.makeWithYMDHM(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40)
188188
// 2023-02-20T16:40:00.000Z
189189

190-
Date.makeWithYMDHM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=60)
190+
Date.makeWithYMDHM(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=60)
191191
// 2023-02-20T17:00:00.000Z
192192

193-
Date.makeWithYMDHM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=-1)
193+
Date.makeWithYMDHM(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=-1)
194194
// 2023-02-20T15:59:00.000Z
195195

196196
// Note: The output depends on your local time zone.
@@ -199,7 +199,7 @@ Date.makeWithYMDHM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=-1)
199199
```
200200
*/
201201
@new
202-
external makeWithYMDHM: (~year: int, ~month: int, ~date: int, ~hours: int, ~minutes: int) => t =
202+
external makeWithYMDHM: (~year: int, ~month: int, ~day: int, ~hours: int, ~minutes: int) => t =
203203
"Date"
204204

205205
/**
@@ -210,13 +210,13 @@ Values, which are out of range, will be carried over to the next bigger unit (s.
210210

211211
## Examples
212212
```rescript
213-
Date.makeWithYMDHMS(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0)
213+
Date.makeWithYMDHMS(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40, ~seconds=0)
214214
// 2023-02-20T16:40:00.000Z
215215

216-
Date.makeWithYMDHMS(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=60)
216+
Date.makeWithYMDHMS(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40, ~seconds=60)
217217
// 2023-02-20T16:41:00.000Z
218218

219-
Date.makeWithYMDHMS(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=-1)
219+
Date.makeWithYMDHMS(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40, ~seconds=-1)
220220
// 2023-02-20T16:39:59.000Z
221221

222222
// Note: The output depends on your local time zone.
@@ -228,7 +228,7 @@ Date.makeWithYMDHMS(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~sec
228228
external makeWithYMDHMS: (
229229
~year: int,
230230
~month: int,
231-
~date: int,
231+
~day: int,
232232
~hours: int,
233233
~minutes: int,
234234
~seconds: int,
@@ -242,13 +242,13 @@ Values, which are out of range, will be carried over to the next bigger unit (s.
242242

243243
## Examples
244244
```rescript
245-
Date.makeWithYMDHMSM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=0)
245+
Date.makeWithYMDHMSM(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=0)
246246
// 2023-02-20T16:40:00.000Z
247247

248-
Date.makeWithYMDHMSM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=1000)
248+
Date.makeWithYMDHMSM(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=1000)
249249
// 2023-02-20T16:40:01.000Z
250250

251-
Date.makeWithYMDHMSM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=-1)
251+
Date.makeWithYMDHMSM(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=-1)
252252
// 2023-02-20T16:39:59.999Z
253253

254254
// Note: The output depends on your local time zone.
@@ -260,7 +260,7 @@ Date.makeWithYMDHMSM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~se
260260
external makeWithYMDHMSM: (
261261
~year: int,
262262
~month: int,
263-
~date: int,
263+
~day: int,
264264
~hours: int,
265265
~minutes: int,
266266
~seconds: int,
@@ -299,18 +299,18 @@ module UTC: {
299299

300300
## Examples
301301
```rescript
302-
Date.UTC.makeWithYMD(~year=2023, ~month=1, ~date=20)
302+
Date.UTC.makeWithYMD(~year=2023, ~month=1, ~day=20)
303303
// 1676851200000
304304

305-
Date.UTC.makeWithYMD(~year=2023, ~month=1, ~date=-1)
305+
Date.UTC.makeWithYMD(~year=2023, ~month=1, ~day=-1)
306306
// 1675036800000
307307

308-
Date.UTC.makeWithYMD(~year=2023, ~month=1, ~date=29)
308+
Date.UTC.makeWithYMD(~year=2023, ~month=1, ~day=29)
309309
// 1677628800000
310310
```
311311
*/
312312
@val
313-
external makeWithYMD: (~year: int, ~month: int, ~date: int) => msSinceEpoch = "Date.UTC"
313+
external makeWithYMD: (~year: int, ~month: int, ~day: int) => msSinceEpoch = "Date.UTC"
314314

315315
/**
316316
Returns the time, in milliseconds, since UNIX epoch (January 1, 1970 00:00:00 UTC).
@@ -320,18 +320,18 @@ module UTC: {
320320

321321
## Examples
322322
```rescript
323-
Date.UTC.makeWithYMDH(~year=2023, ~month=1, ~date=20, ~hours=16)
323+
Date.UTC.makeWithYMDH(~year=2023, ~month=1, ~day=20, ~hours=16)
324324
// 1676908800000
325325

326-
Date.UTC.makeWithYMDH(~year=2023, ~month=1, ~date=20, ~hours=24)
326+
Date.UTC.makeWithYMDH(~year=2023, ~month=1, ~day=20, ~hours=24)
327327
// 1676937600000
328328

329-
Date.UTC.makeWithYMDH(~year=2023, ~month=1, ~date=20, ~hours=-1)
329+
Date.UTC.makeWithYMDH(~year=2023, ~month=1, ~day=20, ~hours=-1)
330330
// 1676847600000
331331
```
332332
*/
333333
@val
334-
external makeWithYMDH: (~year: int, ~month: int, ~date: int, ~hours: int) => msSinceEpoch =
334+
external makeWithYMDH: (~year: int, ~month: int, ~day: int, ~hours: int) => msSinceEpoch =
335335
"Date.UTC"
336336

337337
/**
@@ -342,21 +342,21 @@ module UTC: {
342342

343343
## Examples
344344
```rescript
345-
Date.UTC.makeWithYMDHM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40)
345+
Date.UTC.makeWithYMDHM(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40)
346346
// 1676911200000
347347

348-
Date.UTC.makeWithYMDHM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=60)
348+
Date.UTC.makeWithYMDHM(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=60)
349349
// 1676912400000
350350

351-
Date.UTC.makeWithYMDHM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=-1)
351+
Date.UTC.makeWithYMDHM(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=-1)
352352
// 1676908740000
353353
```
354354
*/
355355
@val
356356
external makeWithYMDHM: (
357357
~year: int,
358358
~month: int,
359-
~date: int,
359+
~day: int,
360360
~hours: int,
361361
~minutes: int,
362362
) => msSinceEpoch = "Date.UTC"
@@ -369,21 +369,21 @@ module UTC: {
369369

370370
## Examples
371371
```rescript
372-
Date.UTC.makeWithYMDHMS(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0)
372+
Date.UTC.makeWithYMDHMS(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40, ~seconds=0)
373373
// 1676911200000
374374

375-
Date.UTC.makeWithYMDHMS(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=60)
375+
Date.UTC.makeWithYMDHMS(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40, ~seconds=60)
376376
// 1676911260000
377377

378-
Date.UTC.makeWithYMDHMS(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=-1)
378+
Date.UTC.makeWithYMDHMS(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40, ~seconds=-1)
379379
// 1676911199000
380380
```
381381
*/
382382
@val
383383
external makeWithYMDHMS: (
384384
~year: int,
385385
~month: int,
386-
~date: int,
386+
~day: int,
387387
~hours: int,
388388
~minutes: int,
389389
~seconds: int,
@@ -397,21 +397,21 @@ module UTC: {
397397

398398
## Examples
399399
```rescript
400-
Date.UTC.makeWithYMDHMSM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=0)->Console.log
400+
Date.UTC.makeWithYMDHMSM(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=0)->Console.log
401401
// 1676911200000
402402

403-
Date.UTC.makeWithYMDHMSM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=1000)->Console.log
403+
Date.UTC.makeWithYMDHMSM(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=1000)->Console.log
404404
// 1676911201000
405405

406-
Date.UTC.makeWithYMDHMSM(~year=2023, ~month=1, ~date=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=-1)->Console.log
406+
Date.UTC.makeWithYMDHMSM(~year=2023, ~month=1, ~day=20, ~hours=16, ~minutes=40, ~seconds=0, ~milliseconds=-1)->Console.log
407407
// 1676911199999
408408
```
409409
*/
410410
@val
411411
external makeWithYMDHMSM: (
412412
~year: int,
413413
~month: int,
414-
~date: int,
414+
~day: int,
415415
~hours: int,
416416
~minutes: int,
417417
~seconds: int,
@@ -607,18 +607,18 @@ Date.fromString("2023-02-20T16:40:00.00")->Date.setFullYearM(~year=2024, ~month=
607607
external setFullYearM: (t, ~year: int, ~month: int) => unit = "setFullYear"
608608

609609
/**
610-
`setFullYearMD(date, ~year, ~month, ~date)`
610+
`setFullYearMD(date, ~year, ~month, ~day)`
611611

612612
Sets the year, month and date (day of month) of a date (according to local time).
613613
Beware this will *mutate* the date.
614614

615615
## Examples
616616
```rescript
617-
Date.fromString("2023-02-20T16:40:00.00")->Date.setFullYearMD(~year=2024, ~month=0, ~date=1)
617+
Date.fromString("2023-02-20T16:40:00.00")->Date.setFullYearMD(~year=2024, ~month=0, ~day=1)
618618
```
619619
*/
620620
@send
621-
external setFullYearMD: (t, ~year: int, ~month: int, ~date: int) => unit = "setFullYear"
621+
external setFullYearMD: (t, ~year: int, ~month: int, ~day: int) => unit = "setFullYear"
622622

623623
/**
624624
`setMonth(date, month)`
@@ -923,18 +923,18 @@ Date.fromString("2023-02-20T16:40:00.00")->Date.setUTCFullYearM(~year=2024, ~mon
923923
external setUTCFullYearM: (t, ~year: int, ~month: int) => unit = "setUTCFullYear"
924924

925925
/**
926-
`setUTCFullYearMD(date, ~year, ~month, ~date)`
926+
`setUTCFullYearMD(date, ~year, ~month, ~day)`
927927

928928
Sets the year, month and date (day of month) of a date (according to UTC time).
929929
Beware this will *mutate* the date.
930930

931931
## Examples
932932
```rescript
933-
Date.fromString("2023-02-20T16:40:00.00")->Date.setUTCFullYearMD(~year=2024, ~month=0, ~date=1)
933+
Date.fromString("2023-02-20T16:40:00.00")->Date.setUTCFullYearMD(~year=2024, ~month=0, ~day=1)
934934
```
935935
*/
936936
@send
937-
external setUTCFullYearMD: (t, ~year: int, ~month: int, ~date: int) => unit = "setUTCFullYear"
937+
external setUTCFullYearMD: (t, ~year: int, ~month: int, ~day: int) => unit = "setUTCFullYear"
938938

939939
/**
940940
`setUTCMonth(date, month)`

0 commit comments

Comments
 (0)