From 62381e59533403e450e620967a0fd36b0822861c Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Mon, 17 Jul 2023 09:55:51 +0800 Subject: [PATCH] refactor: linkage rules support datetime (#2260) * refactor: linkage rules support datetime * refactor: linkage rules support datetime --- .../schema-component/common/utils/logic.js | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/packages/core/client/src/schema-component/common/utils/logic.js b/packages/core/client/src/schema-component/common/utils/logic.js index 59f29fe15..9f0baa6f8 100644 --- a/packages/core/client/src/schema-component/common/utils/logic.js +++ b/packages/core/client/src/schema-component/common/utils/logic.js @@ -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;