From 0a954792ab359546e86c120abe65b596443daafd Mon Sep 17 00:00:00 2001 From: OBKoro1 <1677593011@qq.com> Date: Fri, 20 Dec 2019 18:54:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 34 +++++++++++++++++++++++++++++++--- test.md | 2 +- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 972e397..b0e39cc 100644 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,7 @@ * Author : OBKoro1 * Date : 2019-12-19 20:23:57 * LastEditors : OBKoro1 - * LastEditTime : 2019-12-20 15:47:40 + * LastEditTime : 2019-12-20 18:54:45 * FilePath : /autoCommit/index.js * Description : 自动commit * https://github.com/OBKoro1 @@ -16,11 +16,39 @@ class autoCommit { constructor() { this.init(); } - + getData() { + let time1 = '2019-01-02'; + let time2 = '2019-01-10'; + this.getAll(time1, time2); + } + formatTime(time) { + return `${time} 08:00`; + } + getAll(begin, end) { + let timeArr = []; // TODO: 时间段 + const beginSplit = begin.split('-'); + const endSplit = end.split('-'); + const beginDate = new Date(); + beginDate.setUTCFullYear(beginSplit[0], beginSplit[1] - 1, beginSplit[2]); + const endDate = new Date(); + endDate.setUTCFullYear(endSplit[0], endSplit[1] - 1, endSplit[2]); + const beginNumber = beginDate.getTime(); + const endNumber = endDate.getTime(); + for (var k = timeNumber; k <= endNumber; ) { + console.log(new beginNumber(parseInt(k)).format()); + k = k + 24 * 60 * 60 * 1000; + } + } init() { + this.getData(); const time = moment().format('DD/MM/YYYY HH:MM:ss'); + let time3 = moment('2019-01-02 08:00').format(); + console.log('time', time2, time3); fs.writeFileSync('./test.md', time, 'utf-8'); - this.commit(); + // this.commit(); + } + getTime() { + return ''; } commit() { // git commit --amend --date="2019-01-02T00:00:00+0800" -am 'autoCommit' diff --git a/test.md b/test.md index 38343e3..56a6c40 100644 --- a/test.md +++ b/test.md @@ -1 +1 @@ -20/12/2019 15:12:05 \ No newline at end of file +20/12/2019 17:12:55 \ No newline at end of file