refactor: linkage rules support datetime (#2260)

* refactor: linkage rules support datetime

* refactor: linkage rules support datetime
This commit is contained in:
katherinehhh 2023-07-17 09:55:51 +08:00 committed by GitHub
parent aececf1952
commit 62381e5953
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -150,6 +150,55 @@ http://ricostacruz.com/cheatsheets/umdjs.html
}
return false;
},
$dateOn: function (a, b) {
if (!a || !b) {
return false;
}
const milliseconds1 = new Date(a).getTime();
const milliseconds2 = new Date(b).getTime();
return milliseconds1 === milliseconds2;
},
$dateBefore: function (a, b) {
if (!a || !b) {
return false;
}
return new Date(a) < new Date(b);
},
$dateNotBefore: function (a, b) {
if (!a || !b) {
return false;
}
return new Date(a) <= new Date(b);
},
$dateAfter: function (a, b) {
if (!a || !b) {
return false;
}
return new Date(a) > new Date(b);
},
$dateNotAfter: function (a, b) {
if (!a || !b) {
return false;
}
return new Date(a) >= new Date(b);
},
$dateBetween: function (a, b) {
if (!a || !b) {
return false;
}
const startTime = new Date(b?.[0]);
const endTime = new Date(b?.[1]);
return new Date(a) > startTime && new Date(a) < endTime;
},
$dateNotOn: function (a, b) {
if (!a || !b) {
return false;
}
return new Date(a) != new Date(b);
},
$isTruly: function (a) {
if (Array.isArray(a)) return a.some((k) => k === true || k === 1);
return a === true || a === 1;