refactor(core): Remove dead utils (no-changelog) (#8947)

This commit is contained in:
Iván Ovejero 2024-03-25 17:59:42 +01:00 committed by GitHub
parent 69807a5efb
commit 7d52419d6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 0 additions and 52 deletions

View file

@ -39,18 +39,6 @@ export const findSubworkflowStart = findWorkflowStart('integrated');
export const findCliWorkflowStart = findWorkflowStart('cli'); 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) => { export const separate = <T>(array: T[], test: (element: T) => boolean) => {
const pass: T[] = []; const pass: T[] = [];
const fail: T[] = []; const fail: T[] = [];

View file

@ -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();
}

View file

@ -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');
});
});
});