-
Notifications
You must be signed in to change notification settings - Fork 0
/
Date.cljs
704 lines (475 loc) · 20 KB
/
Date.cljs
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
(ns js.Date
"Creates a JavaScript Date instance that represents a single moment
time in a platform-independent format."
(:refer-clojure :exclude []))
(defn now
"Method.
The Date.now() method returns the number of milliseconds elapsed
January 1, 1970 00:00:00 UTC.
`var timeInMs = Date.now();`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now`"
[this ]
(-> this (.now)))
(defn parse
"Method.
The Date.parse() method parses a string representation of a date,
returns the number of milliseconds since January 1, 1970, 00:00:00
or NaN if the string is unrecognized or, in some cases, contains
date values (e.g. 2015-02-31).
`Direct call:
Date.parse(dateString)
Implicit call:
new Date(dateString)`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse`"
[this & args]
(-> this .-parse (.apply this (clj->js args))))
(defn utc
"Method.
The Date.UTC() method accepts parameters similar to the `js.Date`
but treats them as UTC. It returns the number of milliseconds
January 1, 1970, 00:00:00 UTC.
`ECMAScript 2017 and later:
Date.UTC(year[, month[, day[, hour[, minute[, second[, millisecond]]]]]])
ECMAScript 2016 and earlier: (month used to be required)
Date.UTC(year, month[, day[, hour[, minute[, second[, millisecond]]]]])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC`"
[this & args]
(-> this .-UTC (.apply this (clj->js args))))
(defn get-date
"Method.
The getDate() method returns the day of the month for the specified
according to local time.
`dateObj.getDate()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate`"
[this ]
(-> this (.getDate)))
(defn get-day
"Method.
The getDay() method returns the day of the week for the specified
according to local time, where 0 represents Sunday.
`dateObj.getDay()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay`"
[this ]
(-> this (.getDay)))
(defn get-full-year
"Method.
The getFullYear() method returns the year of the specified date
to local time.
`dateObj.getFullYear()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear`"
[this ]
(-> this (.getFullYear)))
(defn get-hours
"Method.
The getHours() method returns the hour for the specified date,
to local time.
`dateObj.getHours()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours`"
[this ]
(-> this (.getHours)))
(defn get-milliseconds
"Method.
The getMilliseconds() method returns the milliseconds in the
date according to local time.
`dateObj.getMilliseconds()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds`"
[this ]
(-> this (.getMilliseconds)))
(defn get-minutes
"Method.
The getMinutes() method returns the minutes in the specified
according to local time.
`dateObj.getMinutes()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes`"
[this ]
(-> this (.getMinutes)))
(defn get-month
"Method.
The getMonth() method returns the month in the specified date
to local time, as a zero-based value (where zero indicates the
month of the year).
`dateObj.getMonth()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth`"
[this ]
(-> this (.getMonth)))
(defn get-seconds
"Method.
The getSeconds() method returns the seconds in the specified
according to local time.
`dateObj.getSeconds()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds`"
[this ]
(-> this (.getSeconds)))
(defn get-time
"Method.
The getTime() method returns the number of milliseconds* since
Unix Epoch.
`dateObj.getTime()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime`"
[this ]
(-> this (.getTime)))
(defn get-timezone-offset
"Method.
The getTimezoneOffset() method returns the time zone difference,
minutes, from current locale (host system settings) to UTC.
`dateObj.getTimezoneOffset()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset`"
[this ]
(-> this (.getTimezoneOffset)))
(defn get-utc-date
"Method.
The getUTCDate() method returns the day (date) of the month in
specified date according to universal time.
`dateObj.getUTCDate()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate`"
[this ]
(-> this (.getUTCDate)))
(defn get-utc-day
"Method.
The getUTCDay() method returns the day of the week in the specified
according to universal time, where 0 represents Sunday.
`dateObj.getUTCDay()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay`"
[this ]
(-> this (.getUTCDay)))
(defn get-utc-full-year
"Method.
The getUTCFullYear() method returns the year in the specified
according to universal time.
`dateObj.getUTCFullYear()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear`"
[this ]
(-> this (.getUTCFullYear)))
(defn get-utc-hours
"Method.
The getUTCHours() method returns the hours in the specified date
to universal time.
`dateObj.getUTCHours()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours`"
[this ]
(-> this (.getUTCHours)))
(defn get-utc-milliseconds
"Method.
The getUTCMilliseconds() method returns the milliseconds portion
the time object's value.
`dateObj.getUTCMilliseconds()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds`"
[this ]
(-> this (.getUTCMilliseconds)))
(defn get-utc-minutes
"Method.
The getUTCMinutes() method returns the minutes in the specified
according to universal time.
`dateObj.getUTCMinutes()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes`"
[this ]
(-> this (.getUTCMinutes)))
(defn get-utc-month
"Method.
The getUTCMonth() returns the month of the specified date according
universal time, as a zero-based value (where zero indicates the
month of the year).
`dateObj.getUTCMonth()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth`"
[this ]
(-> this (.getUTCMonth)))
(defn get-utc-seconds
"Method.
The getUTCSeconds() method returns the seconds in the specified
according to universal time.
`dateObj.getUTCSeconds()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds`"
[this ]
(-> this (.getUTCSeconds)))
(defn get-year
"Method.
The getYear() method returns the year in the specified date according
local time. Because getYear() does not return full years (\\\"year
problem\\\"), it is no longer used and has been replaced by the
method.
`dateObj.getYear()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getYear`"
[this ]
(-> this (.getYear)))
(defn set-date
"Method.
The setDate() method sets the day of the `js.Date` object relative
the beginning of the currently set month.
`dateObj.setDate(dayValue)`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate`"
[this day-value]
(-> this (.setDate day-value)))
(defn set-full-year
"Method.
The setFullYear() method sets the full year for a specified date
to local time. Returns new timestamp.
`dateObj.setFullYear(yearValue[, monthValue[, dateValue]])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear`"
[this & args]
(-> this .-setFullYear (.apply this (clj->js args))))
(defn set-hours
"Method.
The setHours() method sets the hours for a specified date according
local time, and returns the number of milliseconds since January
1970 00:00:00 UTC until the time represented by the updated `js.Date`
`dateObj.setHours(hoursValue[, minutesValue[, secondsValue[, msValue]]])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours`"
[this & args]
(-> this .-setHours (.apply this (clj->js args))))
(defn set-milliseconds
"Method.
The setMilliseconds() method sets the milliseconds for a specified
according to local time.
`dateObj.setMilliseconds(millisecondsValue)`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds`"
[this milliseconds-value]
(-> this (.setMilliseconds milliseconds-value)))
(defn set-minutes
"Method.
The setMinutes() method sets the minutes for a specified date
to local time.
`dateObj.setMinutes(minutesValue[, secondsValue[, msValue]])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes`"
[this & args]
(-> this .-setMinutes (.apply this (clj->js args))))
(defn set-month
"Method.
The setMonth() method sets the month for a specified date according
the currently set year.
`dateObj.setMonth(monthValue[, dayValue])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth`"
[this & args]
(-> this .-setMonth (.apply this (clj->js args))))
(defn set-seconds
"Method.
The setSeconds() method sets the seconds for a specified date
to local time.
`dateObj.setSeconds(secondsValue[, msValue])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds`"
[this & args]
(-> this .-setSeconds (.apply this (clj->js args))))
(defn set-time
"Method.
The setTime() method sets the `js.Date` object to the time represented
a number of milliseconds since January 1, 1970, 00:00:00 UTC.
`dateObj.setTime(timeValue)`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime`"
[this time-value]
(-> this (.setTime time-value)))
(defn set-utc-date
"Method.
The setUTCDate() method sets the day of the month for a specified
according to universal time.
`dateObj.setUTCDate(dayValue)`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate`"
[this day-value]
(-> this (.setUTCDate day-value)))
(defn set-utc-full-year
"Method.
The setUTCFullYear() method sets the full year for a specified
according to universal time.
`dateObj.setUTCFullYear(yearValue[, monthValue[, dayValue]])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear`"
[this & args]
(-> this .-setUTCFullYear (.apply this (clj->js args))))
(defn set-utc-hours
"Method.
The setUTCHours() method sets the hour for a specified date according
universal time, and returns the number of milliseconds since
1, 1970 00:00:00 UTC until the time represented by the updated
instance.
`dateObj.setUTCHours(hoursValue[, minutesValue[, secondsValue[, msValue]]])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours`"
[this & args]
(-> this .-setUTCHours (.apply this (clj->js args))))
(defn set-utc-milliseconds
"Method.
The setUTCMilliseconds() method sets the milliseconds for a specified
according to universal time.
`dateObj.setUTCMilliseconds(millisecondsValue)`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds`"
[this milliseconds-value]
(-> this (.setUTCMilliseconds milliseconds-value)))
(defn set-utc-minutes
"Method.
The setUTCMinutes() method sets the minutes for a specified date
to universal time.
`dateObj.setUTCMinutes(minutesValue[, secondsValue[, msValue]])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes`"
[this & args]
(-> this .-setUTCMinutes (.apply this (clj->js args))))
(defn set-utc-month
"Method.
The setUTCMonth() method sets the month for a specified date
to universal time.
`dateObj.setUTCMonth(monthValue[, dayValue])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth`"
[this & args]
(-> this .-setUTCMonth (.apply this (clj->js args))))
(defn set-utc-seconds
"Method.
The setUTCSeconds() method sets the seconds for a specified date
to universal time.
`dateObj.setUTCSeconds(secondsValue[, msValue])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds`"
[this & args]
(-> this .-setUTCSeconds (.apply this (clj->js args))))
(defn set-year
"Method.
The setYear() method sets the year for a specified date according
local time. Because setYear() does not set full years (\\\"year
problem\\\"), it is no longer used and has been replaced by the
method.
`dateObj.setYear(yearValue)`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setYear`"
[this year-value]
(-> this (.setYear year-value)))
(defn to-date-string
"Method.
The toDateString() method returns the date portion of a `js.Date`
in English in the following format separated by spaces:
`dateObj.toDateString()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString`"
[this ]
(-> this (.toDateString)))
(defn to-gmt-string
"Method.
The toGMTString() method converts a date to a string, using Internet
Mean Time (GMT) conventions. The exact format of the value returned
toGMTString() varies according to the platform and browser, in
it should represent a human readable date string.
`dateObj.toGMTString()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toGMTString`"
[this ]
(-> this (.toGMTString)))
(defn to-iso-string
"Method.
The toISOString() method returns a string in simplified extended
format (ISO 8601), which is always 24 or 27 characters long (YYYY-MM-DDTHH:mm:ss.sssZ
±YYYYYY-MM-DDTHH:mm:ss.sssZ, respectively). The timezone is always
UTC offset, as denoted by the suffix \\\"Z\\\".
`dateObj.toISOString()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString`"
[this ]
(-> this (.toISOString)))
(defn to-json
"Method.
The toJSON() method returns a string representation of the `js.Date`
`dateObj.toJSON()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON`"
[this ]
(-> this (.toJSON)))
(defn to-locale-date-string
"Method.
The toLocaleDateString() method returns a string with a language
representation of the date portion of this date. The new locales
options arguments let applications specify the language whose
conventions should be used and allow to customize the behavior
the function. In older implementations, which ignore the locales
options arguments, the locale used and the form of the string
are entirely implementation dependent.
`dateObj.toLocaleDateString([locales [, options]])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString`"
[this & args]
(-> this .-toLocaleDateString (.apply this (clj->js args))))
(defn to-locale-format
"Method.
The non-standard toLocaleFormat() method converts a date to a
using the specified formatting. `Intl.DateTimeFormat` is an alternative
format dates in a standards-compliant way. See also the newer
of `Date.prototype.toLocaleDateString()`.
`dateObj.toLocaleFormat(formatString)`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat`"
[this format-string]
(-> this (.toLocaleFormat format-string)))
(defn to-locale-string
"Method.
The toLocaleString() method returns a string with a language
representation of this date. The new locales and options arguments
applications specify the language whose formatting conventions
be used and customize the behavior of the function. In older
which ignore the locales and options arguments, the locale used
the form of the string returned are entirely implementation dependent.
`dateObj.toLocaleString([locales[, options]])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString`"
[this & args]
(-> this .-toLocaleString (.apply this (clj->js args))))
(defn to-locale-time-string
"Method.
The toLocaleTimeString() method returns a string with a language
representation of the time portion of this date. The new locales
options arguments let applications specify the language whose
conventions should be used and customize the behavior of the
In older implementations, which ignore the locales and options
the locale used and the form of the string returned are entirely
dependent.
`dateObj.toLocaleTimeString([locales[, options]])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString`"
[this & args]
(-> this .-toLocaleTimeString (.apply this (clj->js args))))
(defn to-source
"Method.
The toSource() method returns a string representing the source
of the object.
`dateObj.toSource()
Date.toSource()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toSource`"
[this & args]
(-> this .-toSource (.apply this (clj->js args))))
(defn to-string
"Method.
The toString() method returns a string representing the specified
object.
`dateObj.toString()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString`"
[this ]
(-> this (.toString)))
(defn to-time-string
"Method.
The toTimeString() method returns the time portion of a `js.Date`
in human readable form in American English.
`dateObj.toTimeString()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString`"
[this ]
(-> this (.toTimeString)))
(defn to-utc-string
"Method.
The toUTCString() method converts a date to a string, using the
time zone.
`dateObj.toUTCString()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString`"
[this ]
(-> this (.toUTCString)))
(defn value-of
"Method.
The valueOf() method returns the primitive value of a `js.Date`
`dateObj.valueOf()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf`"
[this ]
(-> this (.valueOf)))
(defn prototype
"Property.
The Date.prototype property represents the prototype for the
constructor.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/prototype`"
[this]
(-> this (.-prototype)))
(defn set-prototype!
"Property.
The Date.prototype property represents the prototype for the
constructor.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/prototype`"
[this val]
(aset this "prototype" val))
(defn length
"Property.
The value of Date.length is 7. This is the number of arguments
by the constructor. It's not generally a useful result."
[this]
(-> this (.-length)))
(defn set-length!
"Property.
The value of Date.length is 7. This is the number of arguments
by the constructor. It's not generally a useful result."
[this val]
(aset this "length" val))