keepsafe rework & alert ajustments
All checks were successful
Deploy Sokko G / deploy (push) Successful in 7s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 7s
This commit is contained in:
parent
68005ef918
commit
2e6d8a2c0c
11 changed files with 129 additions and 45 deletions
|
|
@ -81,17 +81,31 @@ export function getTimePatternTargetMs(pattern, nowMs) {
|
|||
const now = new Date(nowMs);
|
||||
const candidate = new Date(nowMs);
|
||||
candidate.setMilliseconds(0);
|
||||
const hasHour = parsed.hours !== "X";
|
||||
const hasMinute = parsed.minutes !== "X";
|
||||
|
||||
for (let offset = 1; offset <= 86400; offset += 1) {
|
||||
candidate.setTime(now.getTime() + offset * 1000);
|
||||
const hours = parsed.hours === "X" || Number(parsed.hours) === candidate.getHours();
|
||||
const minutes = parsed.minutes === "X" || Number(parsed.minutes) === candidate.getMinutes();
|
||||
const seconds = parsed.seconds === "X" || Number(parsed.seconds) === candidate.getSeconds();
|
||||
const minutes = parsed.minutes === "X"
|
||||
? (!hasHour || candidate.getMinutes() === 0)
|
||||
: Number(parsed.minutes) === candidate.getMinutes();
|
||||
const seconds = parsed.seconds === "X"
|
||||
? (!hasHour && !hasMinute) || candidate.getSeconds() === 0
|
||||
: Number(parsed.seconds) === candidate.getSeconds();
|
||||
if (hours && minutes && seconds) return candidate.getTime();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function getTimePatternRecurrenceMs(pattern) {
|
||||
const baseMs = new Date(2026, 0, 1, 0, 0, 0, 0).getTime();
|
||||
const firstTargetMs = getTimePatternTargetMs(pattern, baseMs);
|
||||
if (!firstTargetMs) return 0;
|
||||
const secondTargetMs = getTimePatternTargetMs(pattern, firstTargetMs);
|
||||
return secondTargetMs ? secondTargetMs - firstTargetMs : 0;
|
||||
}
|
||||
|
||||
export function getIntervalTargetMs(intervalMs, anchorAt, nowMs) {
|
||||
const safeIntervalMs = Math.max(1000, Number(intervalMs) || 0);
|
||||
const safeAnchor = Number.isFinite(anchorAt) && anchorAt > 0 ? anchorAt : nowMs;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue