From 1eedfc0abcef8d3b6d7bb044774eee1bdd58c5b4 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Fri, 15 Jul 2022 18:47:36 +0200 Subject: [PATCH] OZG-2500 cleanup dependency --- .../tech-shared/src/lib/date.util.spec.ts | 20 +------------------ .../libs/tech-shared/src/lib/date.util.ts | 13 ------------ goofy-client/package.json | 1 - 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/goofy-client/libs/tech-shared/src/lib/date.util.spec.ts b/goofy-client/libs/tech-shared/src/lib/date.util.spec.ts index 527a8ba18e..e2108d2241 100644 --- a/goofy-client/libs/tech-shared/src/lib/date.util.spec.ts +++ b/goofy-client/libs/tech-shared/src/lib/date.util.spec.ts @@ -2,7 +2,7 @@ import { registerLocaleData } from '@angular/common'; import localeDe from '@angular/common/locales/de'; import { format } from 'date-fns'; import { de } from 'date-fns/locale'; -import { formatForDatabase, formatFullDate, formatFullDateWithTimeAndDay, formatFullDateWithTimeWithoutSeconds, formatToPrettyDate, formatWithoutYear, parseZonedDateTimeStringToLocalDateTime } from './date.util'; +import { formatForDatabase, formatFullDate, formatFullDateWithTimeAndDay, formatFullDateWithTimeWithoutSeconds, formatToPrettyDate, formatWithoutYear } from './date.util'; registerLocaleData(localeDe); @@ -59,22 +59,4 @@ describe('Date Util', () => { expect(result).toEqual('01.01.1010'); }) }) - - describe('parse zoned-date-time-string to date', () => { - - it('should be formatted for same day', () => { - const stringAsDate: Date = parseZonedDateTimeStringToLocalDateTime('2022-07-12T21:00:00Z[UTC]'); - - const formattedDate: string = formatFullDate(stringAsDate); - expect(formattedDate).toBe('12.07.2022'); - }) - - - it('should be formatted for next day', () => { - const stringAsDate: Date = parseZonedDateTimeStringToLocalDateTime('2022-07-12T23:00:00Z[UTC]'); - - const formattedDate: string = formatFullDate(stringAsDate); - expect(formattedDate).toBe('13.07.2022'); - }) - }) }) \ No newline at end of file diff --git a/goofy-client/libs/tech-shared/src/lib/date.util.ts b/goofy-client/libs/tech-shared/src/lib/date.util.ts index 6b9f1b2ee2..5e418625d3 100644 --- a/goofy-client/libs/tech-shared/src/lib/date.util.ts +++ b/goofy-client/libs/tech-shared/src/lib/date.util.ts @@ -44,17 +44,4 @@ export function createFutureDate(todayPlusDays: number): Date { export function isParsableToDate(date: string): boolean { return !isNaN(Date.parse(date)); -} - -export function parseZonedDateTimeStringToLocalDateTime(zonedDateTimeString: string): Date { - return new Date(getLocalDateTime(zonedDateTimeString) + ' ' + getTimeZone(zonedDateTimeString)); -} - -function getLocalDateTime(zonedDateTimeString: string): string { - const dateStringWithoutTz: string = zonedDateTimeString.substring(0, zonedDateTimeString.lastIndexOf('[')); - return dateStringWithoutTz.replace('T', ' ').replace('Z', ''); -} - -function getTimeZone(zonedDateTimeString: string): string { - return zonedDateTimeString.substring(zonedDateTimeString.lastIndexOf('[') + 1, zonedDateTimeString.lastIndexOf(']')); } \ No newline at end of file diff --git a/goofy-client/package.json b/goofy-client/package.json index 81949e2261..7c0f59834f 100644 --- a/goofy-client/package.json +++ b/goofy-client/package.json @@ -68,7 +68,6 @@ "angular-oauth2-oidc": "13.0.1", "angular-oauth2-oidc-jwks": "13.0.1", "date-fns": "^2.28.0", - "date-fns-tz": "^1.3.5", "file-saver": "2.0.5", "include-media": "^1.4.10", "lodash-es": "4.17.21", -- GitLab