mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(distribute) add ability to import config from remote export server
This commit is contained in:
parent
b8e4f9659a
commit
2ad2fc4023
20 changed files with 856 additions and 22 deletions
33
common/datetime.js
Normal file
33
common/datetime.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
const shortdate = require('shortdate');
|
||||
|
||||
module.exports = (date) => {
|
||||
date = date || new Date();
|
||||
check(date);
|
||||
|
||||
const timeStr = shorttime(date);
|
||||
const dateStr = shortdate(date);
|
||||
|
||||
return `${dateStr} ${timeStr}`;
|
||||
};
|
||||
|
||||
const addZero = (a) => {
|
||||
if (a > 9)
|
||||
return a;
|
||||
|
||||
return `0${a}`;
|
||||
};
|
||||
|
||||
function shorttime(date) {
|
||||
const seconds = addZero(date.getSeconds());
|
||||
const minutes = addZero(date.getMinutes());
|
||||
const hours = addZero(date.getHours());
|
||||
|
||||
return `${hours}:${minutes}:${seconds}`;
|
||||
}
|
||||
|
||||
function check(date) {
|
||||
if (!(date instanceof Date))
|
||||
throw Error('date should be instanceof Date!');
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue