1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.utcIntervalMap = exports.utcYear = exports.utcWeek = exports.utcMonth = exports.utcDay = exports.utcHour = exports.utcMinute = exports.utcSecond = exports.utcMillisecond = void 0;
|
4 | const time_interval_1 = require("./time-interval");
|
5 | exports.utcMillisecond = (0, time_interval_1.createInterval)(1, (date) => date, (date, step = 1) => {
|
6 | date.setTime(+date + step);
|
7 | }, (date) => date.getTime());
|
8 | exports.utcSecond = (0, time_interval_1.createInterval)(time_interval_1.DURATION_SECOND, (date) => {
|
9 | date.setUTCMilliseconds(0);
|
10 | }, (date, step = 1) => {
|
11 | date.setTime(+date + time_interval_1.DURATION_SECOND * step);
|
12 | }, (date) => date.getUTCSeconds());
|
13 | exports.utcMinute = (0, time_interval_1.createInterval)(time_interval_1.DURATION_MINUTE, (date) => {
|
14 | date.setUTCSeconds(0, 0);
|
15 | }, (date, step = 1) => {
|
16 | date.setTime(+date + time_interval_1.DURATION_MINUTE * step);
|
17 | }, (date) => date.getUTCMinutes());
|
18 | exports.utcHour = (0, time_interval_1.createInterval)(time_interval_1.DURATION_HOUR, (date) => {
|
19 | date.setUTCMinutes(0, 0, 0);
|
20 | }, (date, step = 1) => {
|
21 | date.setTime(+date + time_interval_1.DURATION_HOUR * step);
|
22 | }, (date) => date.getUTCHours());
|
23 | exports.utcDay = (0, time_interval_1.createInterval)(time_interval_1.DURATION_DAY, (date) => {
|
24 | date.setUTCHours(0, 0, 0, 0);
|
25 | }, (date, step = 1) => {
|
26 | date.setTime(+date + time_interval_1.DURATION_DAY * step);
|
27 | }, (date) => date.getUTCDate() - 1);
|
28 | exports.utcMonth = (0, time_interval_1.createInterval)(time_interval_1.DURATION_MONTH, (date) => {
|
29 | date.setUTCDate(1);
|
30 | date.setUTCHours(0, 0, 0, 0);
|
31 | }, (date, step = 1) => {
|
32 | const month = date.getUTCMonth();
|
33 | date.setUTCMonth(month + step);
|
34 | }, (date) => date.getUTCMonth());
|
35 | exports.utcWeek = (0, time_interval_1.createInterval)(time_interval_1.DURATION_WEEK, (date) => {
|
36 | date.setUTCDate(date.getUTCDate() - ((date.getUTCDay() + 7) % 7));
|
37 | date.setUTCHours(0, 0, 0, 0);
|
38 | }, (date, step = 1) => {
|
39 | date.setTime(+date + time_interval_1.DURATION_WEEK * step);
|
40 | }, (date) => {
|
41 | const start = exports.utcMonth.floor(date);
|
42 | const end = new Date(+date);
|
43 | return Math.floor((+end - +start) / time_interval_1.DURATION_WEEK);
|
44 | });
|
45 | exports.utcYear = (0, time_interval_1.createInterval)(time_interval_1.DURATION_YEAR, (date) => {
|
46 | date.setUTCMonth(0, 1);
|
47 | date.setUTCHours(0, 0, 0, 0);
|
48 | }, (date, step = 1) => {
|
49 | const year = date.getUTCFullYear();
|
50 | date.setUTCFullYear(year + step);
|
51 | }, (date) => date.getUTCFullYear());
|
52 | exports.utcIntervalMap = {
|
53 | millisecond: exports.utcMillisecond,
|
54 | second: exports.utcSecond,
|
55 | minute: exports.utcMinute,
|
56 | hour: exports.utcHour,
|
57 | day: exports.utcDay,
|
58 | week: exports.utcWeek,
|
59 | month: exports.utcMonth,
|
60 | year: exports.utcYear,
|
61 | };
|
62 |
|
\ | No newline at end of file |