mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix: IsWeekend not checking if DateTime (#5221) (no-changelog)
This commit is contained in:
@@ -139,7 +139,10 @@ function isBetween(date: Date | DateTime, extraArgs: unknown[]): boolean {
|
||||
return secondDate > date && date > firstDate;
|
||||
}
|
||||
|
||||
function isDst(date: Date): boolean {
|
||||
function isDst(date: Date | DateTime): boolean {
|
||||
if (isDateTime(date)) {
|
||||
return date.isInDST;
|
||||
}
|
||||
return DateTime.fromJSDate(date).isInDST;
|
||||
}
|
||||
|
||||
@@ -154,11 +157,14 @@ function isInLast(date: Date | DateTime, extraArgs: unknown[]): boolean {
|
||||
return dateInThePast <= thisDate && thisDate <= DateTime.now();
|
||||
}
|
||||
|
||||
function isWeekend(date: Date): boolean {
|
||||
function isWeekend(date: Date | DateTime): boolean {
|
||||
enum DAYS {
|
||||
saturday = 6,
|
||||
sunday = 7,
|
||||
}
|
||||
if (isDateTime(date)) {
|
||||
return [DAYS.saturday, DAYS.sunday].includes(date.weekday);
|
||||
}
|
||||
return [DAYS.saturday, DAYS.sunday].includes(DateTime.fromJSDate(date).weekday);
|
||||
}
|
||||
|
||||
@@ -200,7 +206,7 @@ function toLocaleString(date: Date | DateTime, extraArgs: unknown[]): string {
|
||||
return DateTime.fromJSDate(date).toLocaleString(dateFormat, { locale });
|
||||
}
|
||||
|
||||
function toTimeFromNow(date: Date): string {
|
||||
function toTimeFromNow(date: Date | DateTime): string {
|
||||
let diffObj: Duration;
|
||||
if (isDateTime(date)) {
|
||||
diffObj = date.diffNow();
|
||||
|
||||
Reference in New Issue
Block a user