|
|
@ -10,9 +10,8 @@ export default class Cron {
|
|
|
|
dateToCron() {
|
|
|
|
dateToCron() {
|
|
|
|
if (this.date !== '' && this.time !== '') {
|
|
|
|
if (this.date !== '' && this.time !== '') {
|
|
|
|
let date = new Date(this.date + 'T'+ this.time);
|
|
|
|
let date = new Date(this.date + 'T'+ this.time);
|
|
|
|
console.log(this.date, date, date.getMonth(), date.getDay());
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
cron: `${date.getMinutes()} ${date.getHours()} ${date.getDate()} ${date.getMonth()} *`,
|
|
|
|
cron: `${date.getMinutes()} ${date.getHours()} ${date.getDate()} ${date.getMonth() + 1 } *`,
|
|
|
|
year: date.getFullYear()
|
|
|
|
year: date.getFullYear()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -21,7 +20,7 @@ export default class Cron {
|
|
|
|
|
|
|
|
|
|
|
|
cronToDate() {
|
|
|
|
cronToDate() {
|
|
|
|
let cronArray = this.cron.split(' ');
|
|
|
|
let cronArray = this.cron.split(' ');
|
|
|
|
const month = (parseInt(cronArray[3]) + 1) > 9 ? parseInt(cronArray[3]) + 1 : '0' + (parseInt(cronArray[3]) + 1).toString();
|
|
|
|
const month = (parseInt(cronArray[3])) > 9 ? parseInt(cronArray[3]) : '0' + (parseInt(cronArray[3])).toString();
|
|
|
|
const day = cronArray[2].length < 2 ? '0' + cronArray[2] : cronArray[2];
|
|
|
|
const day = cronArray[2].length < 2 ? '0' + cronArray[2] : cronArray[2];
|
|
|
|
const hour = cronArray[1].length < 2 ? '0'+cronArray[1] : cronArray[1];
|
|
|
|
const hour = cronArray[1].length < 2 ? '0'+cronArray[1] : cronArray[1];
|
|
|
|
const minute = cronArray[0].length < 2 ? '0'+cronArray[0] : cronArray[0];
|
|
|
|
const minute = cronArray[0].length < 2 ? '0'+cronArray[0] : cronArray[0];
|
|
|
|