timeUtil.js
1.24 KB
export 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;
}
export 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];
}
export 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);
}