timeUtil.js
1.41 KB
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
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setTime = setTime;
exports.getLowerBoundTime = getLowerBoundTime;
exports.getLastDay = getLastDay;
function setTime(generateConfig, date, hour, minute, second) {
var nextTime = generateConfig.setHour(date, hour);
nextTime = generateConfig.setMinute(nextTime, minute);
nextTime = generateConfig.setSecond(nextTime, second);
return nextTime;
}
function getLowerBoundTime(hour, minute, second, hourStep, minuteStep, secondStep) {
var lowerBoundHour = Math.floor(hour / hourStep) * hourStep;
if (lowerBoundHour < hour) {
return [lowerBoundHour, 60 - minuteStep, 60 - secondStep];
}
var lowerBoundMinute = Math.floor(minute / minuteStep) * minuteStep;
if (lowerBoundMinute < minute) {
return [lowerBoundHour, lowerBoundMinute, 60 - secondStep];
}
var lowerBoundSecond = Math.floor(second / secondStep) * secondStep;
return [lowerBoundHour, lowerBoundMinute, lowerBoundSecond];
}
function getLastDay(generateConfig, date) {
var year = generateConfig.getYear(date);
var month = generateConfig.getMonth(date) + 1;
var endDate = generateConfig.getEndDate(generateConfig.getFixedDate("".concat(year, "-").concat(month, "-01")));
var lastDay = generateConfig.getDate(endDate);
var monthShow = month < 10 ? "0".concat(month) : "".concat(month);
return "".concat(year, "-").concat(monthShow, "-").concat(lastDay);
}