mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
⚡ Use DATETIMEUNIT_MAP
This commit is contained in:
parent
7bfb00f502
commit
472a77df5c
|
@ -53,6 +53,7 @@ const DURATION_MAP: Record<string, DurationUnit> = {
|
||||||
|
|
||||||
const DATETIMEUNIT_MAP: Record<string, DateTimeUnit> = {
|
const DATETIMEUNIT_MAP: Record<string, DateTimeUnit> = {
|
||||||
days: 'day',
|
days: 'day',
|
||||||
|
week: 'weekNumber',
|
||||||
months: 'month',
|
months: 'month',
|
||||||
years: 'year',
|
years: 'year',
|
||||||
hours: 'hour',
|
hours: 'hour',
|
||||||
|
@ -117,10 +118,6 @@ function extract(inputDate: Date | DateTime, extraArgs: DatePart[]): number | Da
|
||||||
return Math.floor(diff / (1000 * 60 * 60 * 24));
|
return Math.floor(diff / (1000 * 60 * 60 * 24));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (part === 'week') {
|
|
||||||
part = 'weekNumber';
|
|
||||||
}
|
|
||||||
|
|
||||||
return DateTime.fromJSDate(date).get((DATETIMEUNIT_MAP[part] as keyof DateTime) || part);
|
return DateTime.fromJSDate(date).get((DATETIMEUNIT_MAP[part] as keyof DateTime) || part);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue