作业功能

This commit is contained in:
masnn committed 2020-06-02 11:33:40 +08:00
1 parent 216a4a91e4
commit bc50913e6e
60 files changed
+1161 -197

No files matched your search

+17
View File
@@ -14,6 +14,10 @@ Array.isDiff = function isDiff(a, b) {
return false;
};
/**
* @param {string} format %Y-%m-%d %H:%M:%S
* @returns {string} Formatted date string
*/
Date.prototype.format = function formatDate(fmt = '%Y-%m-%d %H:%M:%S') {
return fmt
.replace('%Y', this.getFullYear())
@@ -25,6 +29,19 @@ Date.prototype.format = function formatDate(fmt = '%Y-%m-%d %H:%M:%S') {
.replace('%S', this.getSeconds());
};
/**
* @param {object} param0
* @returns {Date}
*/
Date.prototype.delta = function delta({
year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0,
}) {
let ts = this.getTime();
ts += second * 1000 + minute * 60000 + hour * 60 * 60000;
ts += day * 24 * 60 * 60000 + month * 30 * 24 * 60 * 60000 + year * 365 * 24 * 60 * 60000;
return new Date(ts);
};
Set.isSuperset = function isSuperset(set, subset) {
for (const elem of subset) {
if (!set.has(elem)) return false;