mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-23 11:44:06 -08:00
refactor(core): Remove dead utils (no-changelog) (#8947)
This commit is contained in:
parent
69807a5efb
commit
7d52419d6f
|
@ -39,18 +39,6 @@ export const findSubworkflowStart = findWorkflowStart('integrated');
|
|||
|
||||
export const findCliWorkflowStart = findWorkflowStart('cli');
|
||||
|
||||
export const alphabetizeKeys = (obj: INode) =>
|
||||
Object.keys(obj)
|
||||
.sort()
|
||||
.reduce<Partial<INode>>(
|
||||
(acc, key) => ({
|
||||
...acc,
|
||||
// @ts-expect-error @TECH_DEBT Adding index signature to INode causes type issues downstream
|
||||
[key]: obj[key],
|
||||
}),
|
||||
{},
|
||||
);
|
||||
|
||||
export const separate = <T>(array: T[], test: (element: T) => boolean) => {
|
||||
const pass: T[] = [];
|
||||
const fail: T[] = [];
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
import { DateTime } from 'luxon';
|
||||
|
||||
export function toUtcDate(datetime: Date, tz: string) {
|
||||
return DateTime.fromISO(datetime.toISOString().slice(0, -1), { zone: tz }).toUTC().toJSDate();
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
import { toUtcDate } from '@/utils';
|
||||
|
||||
describe('utils', () => {
|
||||
describe('toUtcDate()', () => {
|
||||
test('should convert to UTC date by adding', () => {
|
||||
const originalDate = new Date('2020-01-01T00:00:00.000Z');
|
||||
const timezone = 'America/New_York'; // +5 to reach Z
|
||||
|
||||
const utcDate = toUtcDate(originalDate, timezone);
|
||||
|
||||
expect(utcDate).toBeInstanceOf(Date);
|
||||
expect(utcDate.toISOString()).toBe('2020-01-01T05:00:00.000Z');
|
||||
});
|
||||
|
||||
test('should convert to UTC date by subtracting', () => {
|
||||
const originalDate = new Date('2020-01-01T00:00:00.000Z');
|
||||
const timezone = 'Europe/Paris'; // -1 to reach Z
|
||||
|
||||
const utcDate = toUtcDate(originalDate, timezone);
|
||||
|
||||
expect(utcDate).toBeInstanceOf(Date);
|
||||
expect(utcDate.toISOString()).toBe('2019-12-31T23:00:00.000Z');
|
||||
});
|
||||
|
||||
test('should convert to UTC date when already UTC', () => {
|
||||
const originalDate = new Date('2020-01-01T00:00:00.000Z');
|
||||
const timezone = 'UTC'; // already at Z
|
||||
|
||||
const utcDate = toUtcDate(originalDate, timezone);
|
||||
|
||||
expect(utcDate).toBeInstanceOf(Date);
|
||||
expect(utcDate.toISOString()).toBe('2020-01-01T00:00:00.000Z');
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue