-
Notifications
You must be signed in to change notification settings - Fork 465
/
Copy pathJs_date.res
1382 lines (1160 loc) · 43.1 KB
/
Js_date.res
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright (C) 2015-2016 Bloomberg Finance L.P.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition to the permissions granted to you by the LGPL, you may combine
* or link a "work that uses the Library" with a publicly distributed version
* of this file to produce a combined library or application, then distribute
* that combined work under the terms of your choosing, with no requirement
* to comply with the obligations normally placed on you by section 4 of the
* LGPL version 3 (or the corresponding section of a later version of the LGPL
* should you choose to use a later version).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/***
Provide bindings to JS date. (See
[`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
on MDN.) JavaScript stores dates as the number of milliseconds since the UNIX
*epoch*, midnight 1 January 1970, UTC.
*/
type t = Stdlib_Date.t
@send
/**
Returns the primitive value of this date, equivalent to `getTime()`. (See
[`Date.valueOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf)
on MDN.)
## Examples
```rescript
Js.Date.valueOf(exampleDate) == 123456654321.0
```
*/
external valueOf: t => float = "valueOf"
@new
/**
Returns a date representing the current time. See [`Date()`
Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)
on MDN.
## Examples
```rescript
let now = Js.Date.make()
```
*/
external make: unit => t = "Date"
@new
/**
Returns a date representing the given argument, which is a number of
milliseconds since the epoch. See [`Date()`
Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)
on MDN.
## Examples
```rescript
Js.Date.fromFloat(123456654321.0) == exampleDate
```
*/
external fromFloat: float => t = "Date"
@new
/**
Returns a `Js.Date.t` represented by the given string. The string can be in
“IETF-compliant RFC 2822 timestamps, and also strings in a version of ISO8601.”
Returns `NaN` if given an invalid date string. According to the [`Date()`
Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)
documentation on MDN, its use is discouraged.
## Examples
```rescript
Js.Date.fromString("Thu, 29 Nov 1973 21:30:54.321 GMT") == exampleDate
Js.Date.fromString("1973-11-29T21:30:54.321Z00:00") == exampleDate
Js.Date.fromString("Thor, 32 Lok -19 60:70:80 XYZ") // returns NaN
```
*/
external fromString: string => t = "Date"
@new
/**
Returns a date representing midnight of the first day of the given month and
year in the current time zone. Fractional parts of arguments are ignored. See
[`Date()`
Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)
on MDN.
## Examples
```rescript
let november1 = Js.Date.makeWithYM(~year=2020.0, ~month=10.0, ())
```
*/
external makeWithYM: (~year: float, ~month: float, unit) => t = "Date"
@new
/**
Returns a date representing midnight of the given date of the given month and
year in the current time zone. Fractional parts of arguments are ignored. See
[`Date()`
Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)
on MDN.
*/
external makeWithYMD: (~year: float, ~month: float, ~date: float, unit) => t = "Date"
@new
/**
Returns a date representing the given date of the given month and year, at zero
minutes and zero seconds past the given `hours`, in the current time zone.
Fractional parts of arguments are ignored. See [`Date()`
Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)
on MDN. Fractional parts of the arguments are ignored.
*/
external makeWithYMDH: (~year: float, ~month: float, ~date: float, ~hours: float, unit) => t =
"Date"
@new
/**
Returns a date representing the given date of the given month and year, at zero
seconds past the given time in hours and minutes in the current time zone.
Fractional parts of arguments are ignored. See [`Date()`
Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)
on MDN.
*/
external makeWithYMDHM: (
~year: float,
~month: float,
~date: float,
~hours: float,
~minutes: float,
unit,
) => t = "Date"
@new
/**
Returns a date representing the given date of the given month and year, at the
given time in hours, minutes, and seconds in the current time zone. Fractional
parts of arguments are ignored. See [`Date()`
Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date)
on MDN.
## Examples
```rescript
Js.Date.makeWithYMDHMS(
~year=1973.0,
~month=11.0,
~date=29.0,
~hours=21.0,
~minutes=30.0,
~seconds=54.321,
(),
) == exampleDate
```
*/
external makeWithYMDHMS: (
~year: float,
~month: float,
~date: float,
~hours: float,
~minutes: float,
~seconds: float,
unit,
) => t = "Date"
@val("Date.UTC")
/**
Returns a float representing the number of milliseconds past the epoch for
midnight of the first day of the given month and year in UTC. Fractional parts
of arguments are ignored. See
[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)
on MDN.
## Examples
```rescript
let november1 = Js.Date.utcWithYM(~year=2020.0, ~month=10.0, ())
```
*/
external utcWithYM: (~year: float, ~month: float, unit) => float = ""
@val("Date.UTC")
/**
Returns a float representing the number of milliseconds past the epoch for
midnight of the given date of the given month and year in UTC. Fractional parts
of arguments are ignored. See
[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)
on MDN.
*/
external utcWithYMD: (~year: float, ~month: float, ~date: float, unit) => float = ""
@val("Date.UTC")
/**
Returns a float representing the number of milliseconds past the epoch for
midnight of the given date of the given month and year, at zero minutes and
seconds past the given hours in UTC. Fractional parts of arguments are ignored.
See
[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)
on MDN.
*/
external utcWithYMDH: (~year: float, ~month: float, ~date: float, ~hours: float, unit) => float = ""
@val("Date.UTC")
/**
Returns a float representing the number of milliseconds past the epoch for
midnight of the given date of the given month and year, at zero seconds past
the given number of minutes past the given hours in UTC. Fractional parts of
arguments are ignored. See
[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)
on MDN.
*/
external utcWithYMDHM: (
~year: float,
~month: float,
~date: float,
~hours: float,
~minutes: float,
unit,
) => float = ""
@val("Date.UTC")
/**
Returns a float representing the number of milliseconds past the epoch for
midnight of the given date of the given month and year, at the given time in
hours, minutes and seconds in UTC. Fractional parts of arguments are ignored.
See
[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC)
on MDN.
*/
external utcWithYMDHMS: (
~year: float,
~month: float,
~date: float,
~hours: float,
~minutes: float,
~seconds: float,
unit,
) => float = ""
@val("Date.now") /** Returns the current time as number of milliseconds since Unix epoch. */
external now: unit => float = ""
@new @deprecated("Please use `fromString` instead") external parse: string => t = "Date"
@val("parse")
@scope("Date")
/**
Returns a float with the number of milliseconds past the epoch represented by
the given string. The string can be in “IETF-compliant RFC 2822 timestamps, and
also strings in a version of ISO8601.” Returns `NaN` if given an invalid date
string. According to the
[`Date.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse)
documentation on MDN, its use is discouraged. Returns `NaN` if passed invalid
date string.
*/
external parseAsFloat: string => float = ""
@send
/**
Returns the day of the month for its argument. The argument is evaluated in the
current time zone. See
[`Date.getDate`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate)
on MDN.
## Examples
```rescript
Js.Date.getDate(exampleDate) == 29.0
```
*/
external getDate: t => float = "getDate"
@send
/**
Returns the day of the week (0.0-6.0) for its argument, where 0.0 represents
Sunday. The argument is evaluated in the current time zone. See
[`Date.getDay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay)
on MDN.
## Examples
```rescript
Js.Date.getDay(exampleDate) == 4.0
```
*/
external getDay: t => float = "getDay"
@send
/**
Returns the full year (as opposed to the range 0-99) for its argument. The
argument is evaluated in the current time zone. See
[`Date.getFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear)
on MDN.
## Examples
```rescript
Js.Date.getFullYear(exampleDate) == 1973.0
```
*/
external getFullYear: t => float = "getFullYear"
@send
/**
Returns the hours for its argument, evaluated in the current time zone. See
[`Date.getHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours)
on MDN.
## Examples
```rescript
Js.Date.getHours(exampleDate) == 22.0 // Vienna is in GMT+01:00
```
*/
external getHours: t => float = "getHours"
@send
/**
Returns the number of milliseconds for its argument, evaluated in the current
time zone. See
[`Date.getMilliseconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds)
on MDN.
## Examples
```rescript
Js.Date.getMilliseconds(exampleDate) == 321.0
```
*/
external getMilliseconds: t => float = "getMilliseconds"
@send
/**
Returns the number of minutes for its argument, evaluated in the current time
zone. See
[`Date.getMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes)
on MDN.
## Examples
```rescript
Js.Date.getMinutes(exampleDate) == 30.0
```
*/
external getMinutes: t => float = "getMinutes"
@send
/**
Returns the month (0.0-11.0) for its argument, evaluated in the current time
zone. January is month zero. See
[`Date.getMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth)
on MDN.
## Examples
```rescript
Js.Date.getMonth(exampleDate) == 10.0
```
*/
external getMonth: t => float = "getMonth"
@send
/**
Returns the seconds for its argument, evaluated in the current time zone. See
[`Date.getSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds)
on MDN.
## Examples
```rescript
Js.Date.getSeconds(exampleDate) == 54.0
```
*/
external getSeconds: t => float = "getSeconds"
@send
/**
Returns the number of milliseconds since Unix epoch, evaluated in UTC. See
[`Date.getTime`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime)
on MDN.
## Examples
```rescript
Js.Date.getTime(exampleDate) == 123456654321.0
```
*/
external getTime: t => float = "getTime"
@send
/**
Returns the time zone offset in minutes from the current time zone to UTC. See
[`Date.getTimezoneOffset`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
on MDN.
## Examples
```rescript
Js.Date.getTimezoneOffset(exampleDate) == -60.0
```
*/
external getTimezoneOffset: t => float = "getTimezoneOffset"
@send
/**
Returns the day of the month of the argument, evaluated in UTC. See
[`Date.getUTCDate`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate)
on MDN.
## Examples
```rescript
Js.Date.getUTCDate(exampleDate) == 29.0
```
*/
external getUTCDate: t => float = "getUTCDate"
@send
/**
Returns the day of the week of the argument, evaluated in UTC. The range of the
return value is 0.0-6.0, where Sunday is zero. See
[`Date.getUTCDay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay)
on MDN.
## Examples
```rescript
Js.Date.getUTCDay(exampleDate) == 4.0
```
*/
external getUTCDay: t => float = "getUTCDay"
@send
/**
Returns the full year (as opposed to the range 0-99) for its argument. The
argument is evaluated in UTC. See
[`Date.getUTCFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear)
on MDN.
## Examples
```rescript
Js.Date.getUTCFullYear(exampleDate) == 1973.0
```
*/
external getUTCFullYear: t => float = "getUTCFullYear"
@send
/**
Returns the hours for its argument, evaluated in the current time zone. See
[`Date.getUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours)
on MDN.
## Examples
```rescript
Js.Date.getUTCHours(exampleDate) == 21.0
```
*/
external getUTCHours: t => float = "getUTCHours"
@send
/**
Returns the number of milliseconds for its argument, evaluated in UTC. See
[`Date.getUTCMilliseconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds)
on MDN.
## Examples
```rescript
Js.Date.getUTCMilliseconds(exampleDate) == 321.0
```
*/
external getUTCMilliseconds: t => float = "getUTCMilliseconds"
@send
/**
Returns the number of minutes for its argument, evaluated in UTC. See
[`Date.getUTCMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes)
on MDN.
## Examples
```rescript
Js.Date.getUTCMinutes(exampleDate) == 30.0
```
*/
external getUTCMinutes: t => float = "getUTCMinutes"
@send
/**
Returns the month (0.0-11.0) for its argument, evaluated in UTC. January is
month zero. See
[`Date.getUTCMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth)
on MDN.
## Examples
```rescript
Js.Date.getUTCMonth(exampleDate) == 10.0
```
*/
external getUTCMonth: t => float = "getUTCMonth"
@send
/**
Returns the seconds for its argument, evaluated in UTC. See
[`Date.getUTCSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds)
on MDN.
## Examples
```rescript
Js.Date.getUTCSeconds(exampleDate) == 54.0
```
*/
external getUTCSeconds: t => float = "getUTCSeconds"
@send @deprecated("Use `getFullYear` instead.") external getYear: t => float = "getYear"
@send
/**
Sets the given `Date`’s day of month to the value in the second argument
according to the current time zone. Returns the number of milliseconds since
the epoch of the updated `Date`. *This function modifies the original `Date`.*
See
[`Date.setDate`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let twoWeeksBefore = Js.Date.setDate(date1, 15.0)
date1 == Js.Date.fromString("1973-11-15T21:30:54.321Z00:00")
twoWeeksBefore == Js.Date.getTime(date1)
```
*/
external setDate: (t, float) => float = "setDate"
@send
/**
Sets the given `Date`’s year to the value in the second argument according to
the current time zone. Returns the number of milliseconds since the epoch of
the updated `Date`. *This function modifies the original `Date`.* See
[`Date.setFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let nextYear = Js.Date.setFullYear(date1, 1974.0)
date1 == Js.Date.fromString("1974-11-15T21:30:54.321Z00:00")
nextYear == Js.Date.getTime(date1)
```
*/
external setFullYear: (t, float) => float = "setFullYear"
@send
/**
Sets the given `Date`’s year and month to the values in the labeled arguments
according to the current time zone. Returns the number of milliseconds since
the epoch of the updated `Date`. *This function modifies the original `Date`.*
See
[`Date.setFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let future = Js.Date.setFullYearM(date1, ~year=1974.0, ~month=0.0, ())
date1 == Js.Date.fromString("1974-01-22T21:30:54.321Z00:00")
future == Js.Date.getTime(date1)
```
*/
external setFullYearM: (t, ~year: float, ~month: float, unit) => float = "setFullYear"
@send
/**
Sets the given `Date`’s year, month, and day of month to the values in the
labeled arguments according to the current time zone. Returns the number of
milliseconds since the epoch of the updated `Date`. *This function modifies the
original `Date`.* See
[`Date.setFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let future = Js.Date.setFullYearMD(date1, ~year=1974.0, ~month=0.0, ~date=7.0, ())
date1 == Js.Date.fromString("1974-01-07T21:30:54.321Z00:00")
future == Js.Date.getTime(date1)
```
*/
external setFullYearMD: (t, ~year: float, ~month: float, ~date: float, unit) => float =
"setFullYear"
@send
/**
Sets the given `Date`’s hours to the value in the second argument according to
the current time zone. Returns the number of milliseconds since the epoch of
the updated `Date`. *This function modifies the original `Date`.* See
[`Date.setHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let nextHour = Js.Date.setHours(date1, 22.0)
date1 == Js.Date.fromString("1973-11-29T22:30:54.321Z00:00")
nextHour == Js.Date.getTime(date1)
```
*/
external setHours: (t, float) => float = "setHours"
@send
/**
Sets the given `Date`’s hours and minutes to the values in the labeled
arguments according to the current time zone. Returns the number of
milliseconds since the epoch of the updated `Date`. *This function modifies the
original `Date`.* See
[`Date.setHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let futureTime = Js.Date.setHoursM(date1, ~hours=22.0, ~minutes=46.0, ())
date1 == Js.Date.fromString("1973-11-29T22:46:54.321Z00:00")
futureTime == Js.Date.getTime(date1)
```
*/
external setHoursM: (t, ~hours: float, ~minutes: float, unit) => float = "setHours"
@send
/**
Sets the given `Date`’s hours, minutes, and seconds to the values in the
labeled arguments according to the current time zone. Returns the number of
milliseconds since the epoch of the updated `Date`. *This function modifies the
original `Date`.* See
[`Date.setHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let futureTime = Js.Date.setHoursMS(date1, ~hours=22.0, ~minutes=46.0, ~seconds=37.0, ())
date1 == Js.Date.fromString("1973-11-29T22:46:37.321Z00:00")
futureTime == Js.Date.getTime(date1)
```
*/
external setHoursMS: (t, ~hours: float, ~minutes: float, ~seconds: float, unit) => float =
"setHours"
@send
/**
Sets the given `Date`’s hours, minutes, seconds, and milliseconds to the values
in the labeled arguments according to the current time zone. Returns the number
of milliseconds since the epoch of the updated `Date`. *This function modifies
the original `Date`.* See
[`Date.setHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let futureTime = Js.Date.setHoursMSMs(
date1,
~hours=22.0,
~minutes=46.0,
~seconds=37.0,
~milliseconds=494.0,
(),
)
date1 == Js.Date.fromString("1973-11-29T22:46:37.494Z00:00")
futureTime == Js.Date.getTime(date1)
```
*/
external setHoursMSMs: (
t,
~hours: float,
~minutes: float,
~seconds: float,
~milliseconds: float,
unit,
) => float = "setHours"
@send
/**
Sets the given `Date`’s milliseconds to the value in the second argument
according to the current time zone. Returns the number of milliseconds since
the epoch of the updated `Date`. *This function modifies the original `Date`.*
See
[`Date.setMilliseconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let futureTime = Js.Date.setMilliseconds(date1, 494.0)
date1 == Js.Date.fromString("1973-11-29T21:30:54.494Z00:00")
futureTime == Js.Date.getTime(date1)
```
*/
external setMilliseconds: (t, float) => float = "setMilliseconds"
@send
/**
Sets the given `Date`’s minutes to the value in the second argument according
to the current time zone. Returns the number of milliseconds since the epoch of
the updated `Date`. *This function modifies the original `Date`.* See
[`Date.setMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let futureTime = Js.Date.setMinutes(date1, 34.0)
date1 == Js.Date.fromString("1973-11-29T21:34:54.494Z00:00")
futureTime == Js.Date.getTime(date1)
```
*/
external setMinutes: (t, float) => float = "setMinutes"
@send
/**
Sets the given `Date`’s minutes and seconds to the values in the labeled
arguments according to the current time zone. Returns the number of
milliseconds since the epoch of the updated `Date`. *This function modifies the
original `Date`.* See
[`Date.setMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let futureTime = Js.Date.setMinutesS(date1, ~minutes=34.0, ~seconds=56.0, ())
date1 == Js.Date.fromString("1973-11-29T21:34:56.494Z00:00")
futureTime == Js.Date.getTime(date1)
```
*/
external setMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float = "setMinutes"
@send
/**
Sets the given `Date`’s minutes, seconds, and milliseconds to the values in the
labeled arguments according to the current time zone. Returns the number of
milliseconds since the epoch of the updated `Date`. *This function modifies the
original `Date`.* See
[`Date.setMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let futureTime = Js.Date.setMinutesSMs(
date1,
~minutes=34.0,
~seconds=56.0,
~milliseconds=789.0,
(),
)
date1 == Js.Date.fromString("1973-11-29T21:34:56.789Z00:00")
futureTime == Js.Date.getTime(date1)
```
*/
external setMinutesSMs: (t, ~minutes: float, ~seconds: float, ~milliseconds: float, unit) => float =
"setMinutes"
@send
/**
Sets the given `Date`’s month to the value in the second argument according to
the current time zone. Returns the number of milliseconds since the epoch of
the updated `Date`. *This function modifies the original `Date`.* See
[`Date.setMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let futureTime = Js.Date.setMonth(date1, 11.0)
date1 == Js.Date.fromString("1973-12-29T21:34:56.789Z00:00")
futureTime == Js.Date.getTime(date1)
```
*/
external setMonth: (t, float) => float = "setMonth"
@send
/**
Sets the given `Date`’s month and day of month to the values in the labeled
arguments according to the current time zone. Returns the number of
milliseconds since the epoch of the updated `Date`. *This function modifies the
original `Date`.* See
[`Date.setMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let futureTime = Js.Date.setMonthD(date1, ~month=11.0, ~date=8.0, ())
date1 == Js.Date.fromString("1973-12-08T21:34:56.789Z00:00")
futureTime == Js.Date.getTime(date1)
```
*/
external setMonthD: (t, ~month: float, ~date: float, unit) => float = "setMonth"
@send
/**
Sets the given `Date`’s seconds to the value in the second argument according
to the current time zone. Returns the number of milliseconds since the epoch of
the updated `Date`. *This function modifies the original `Date`.* See
[`Date.setSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let futureTime = Js.Date.setSeconds(date1, 56.0)
date1 == Js.Date.fromString("1973-12-29T21:30:56.321Z00:00")
futureTime == Js.Date.getTime(date1)
```
*/
external setSeconds: (t, float) => float = "setSeconds"
@send
/**
Sets the given `Date`’s seconds and milliseconds to the values in the labeled
arguments according to the current time zone. Returns the number of
milliseconds since the epoch of the updated `Date`. *This function modifies the
original `Date`.* See
[`Date.setSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let futureTime = Js.Date.setSecondsMs(date1, ~seconds=56.0, ~milliseconds=789.0, ())
date1 == Js.Date.fromString("1973-12-29T21:30:56.789Z00:00")
futureTime == Js.Date.getTime(date1)
```
*/
external setSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float = "setSeconds"
@send
/**
Sets the given `Date`’s value in terms of milliseconds since the epoch. Returns
the number of milliseconds since the epoch of the updated `Date`. *This
function modifies the original `Date`.* See
[`Date.setTime`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let futureTime = Js.Date.setTime(date1, 198765432101.0)
date1 == Js.Date.fromString("1976-04-19T12:37:12.101Z00:00")
futureTime == Js.Date.getTime(date1)
```
*/
external setTime: (t, float) => float = "setTime"
@send
/**
Sets the given `Date`’s day of month to the value in the second argument
according to UTC. Returns the number of milliseconds since the epoch of the
updated `Date`. *This function modifies the original `Date`.* See
[`Date.setUTCDate`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let twoWeeksBefore = Js.Date.setUTCDate(date1, 15.0)
date1 == Js.Date.fromString("1973-11-15T21:30:54.321Z00:00")
twoWeeksBefore == Js.Date.getTime(date1)
```
*/
external setUTCDate: (t, float) => float = "setUTCDate"
@send
/**
Sets the given `Date`’s year to the value in the second argument according to
UTC. Returns the number of milliseconds since the epoch of the updated `Date`.
*This function modifies the original `Date`.* See
[`Date.setUTCFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let nextYear = Js.Date.setUTCFullYear(date1, 1974.0)
date1 == Js.Date.fromString("1974-11-15T21:30:54.321Z00:00")
nextYear == Js.Date.getTime(date1)
```
*/
external setUTCFullYear: (t, float) => float = "setUTCFullYear"
@send
/**
Sets the given `Date`’s year and month to the values in the labeled arguments
according to UTC. Returns the number of milliseconds since the epoch of the
updated `Date`. *This function modifies the original `Date`.* See
[`Date.setUTCFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let future = Js.Date.setUTCFullYearM(date1, ~year=1974.0, ~month=0.0, ())
date1 == Js.Date.fromString("1974-01-22T21:30:54.321Z00:00")
future == Js.Date.getTime(date1)
```
*/
external setUTCFullYearM: (t, ~year: float, ~month: float, unit) => float = "setUTCFullYear"
@send
/**
Sets the given `Date`’s year, month, and day of month to the values in the
labeled arguments according to UTC. Returns the number of milliseconds since
the epoch of the updated `Date`. *This function modifies the original `Date`.*
See
[`Date.setUTCFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let future = Js.Date.setUTCFullYearMD(date1, ~year=1974.0, ~month=0.0, ~date=7.0, ())
date1 == Js.Date.fromString("1974-01-07T21:30:54.321Z00:00")
future == Js.Date.getTime(date1)
```
*/
external setUTCFullYearMD: (t, ~year: float, ~month: float, ~date: float, unit) => float =
"setUTCFullYear"
@send
/**
Sets the given `Date`’s hours to the value in the second argument according to
UTC. Returns the number of milliseconds since the epoch of the updated `Date`.
*This function modifies the original `Date`.* See
[`Date.setUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours)
on MDN.
## Examples
```rescript
let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT
let nextHour = Js.Date.setUTCHours(date1, 22.0)
date1 == Js.Date.fromString("1973-11-29T22:30:54.321Z00:00")
nextHour == Js.Date.getTime(date1)
```
*/
external setUTCHours: (t, float) => float = "setUTCHours"
@send
/**
Sets the given `Date`’s hours and minutes to the values in the labeled
arguments according to UTC. Returns the number of milliseconds since the epoch
of the updated `Date`. *This function modifies the original `Date`.* See
[`Date.setUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours)
on MDN.
## Examples