From e04bda73e302060e4cb1b19cd239018a61f6abf5 Mon Sep 17 00:00:00 2001 From: Andrei Caleniuc Date: Tue, 21 Mar 2023 12:52:33 +0200 Subject: [PATCH] chore: remove moment --- package-lock.json | 54 -- package.json | 3 - .../src/ui-dateformat.directive.luxon.spec.ts | 531 ------------------ .../src/ui-dateformat.directive.spec.ts | 197 ++----- .../src/ui-dateformat.directive.ts | 55 +- .../ui-secondformat.directive.luxon.spec.ts | 164 ------ .../src/ui-secondformat.directive.spec.ts | 22 +- .../src/ui-secondformat.directive.ts | 30 +- projects/angular/package.json | 2 - 9 files changed, 86 insertions(+), 972 deletions(-) delete mode 100644 projects/angular/directives/ui-dateformat/src/ui-dateformat.directive.luxon.spec.ts delete mode 100644 projects/angular/directives/ui-secondformat/src/ui-secondformat.directive.luxon.spec.ts diff --git a/package-lock.json b/package-lock.json index 2958098fc..39302510e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,8 +23,6 @@ "humanize-duration": "3.28.0", "lodash-es": "4.17.21", "luxon": "3.2.1", - "moment": "2.29.4", - "moment-timezone": "0.5.39", "object-hash": "2.2.0", "rxjs": "^7.5.7", "scroll-into-view-if-needed": "2.2.28", @@ -57,7 +55,6 @@ "@types/jasminewd2": "2.0.6", "@types/lodash-es": "4.17.4", "@types/luxon": "3.2.0", - "@types/moment-timezone": "0.5.30", "@types/object-hash": "2.1.0", "@types/uuid": "^9.0.0", "@typescript-eslint/eslint-plugin": "^5.44.0", @@ -5538,16 +5535,6 @@ "integrity": "sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==", "dev": true }, - "node_modules/@types/moment-timezone": { - "version": "0.5.30", - "resolved": "https://registry.npmjs.org/@types/moment-timezone/-/moment-timezone-0.5.30.tgz", - "integrity": "sha512-aDVfCsjYnAQaV/E9Qc24C5Njx1CoDjXsEgkxtp9NyXDpYu4CCbmclb6QhWloS9UTU/8YROUEEdEkWI0D7DxnKg==", - "deprecated": "This is a stub types definition. moment-timezone provides its own type definitions, so you do not need this installed.", - "dev": true, - "dependencies": { - "moment-timezone": "*" - } - }, "node_modules/@types/ms": { "version": "0.7.31", "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz", @@ -17225,25 +17212,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/moment": { - "version": "2.29.4", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", - "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", - "engines": { - "node": "*" - } - }, - "node_modules/moment-timezone": { - "version": "0.5.39", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.39.tgz", - "integrity": "sha512-hoB6suq4ISDj7BDgctiOy6zljBsdYT0++0ZzZm9rtxIvJhIbQ3nmbgSWe7dNFGurl6/7b1OUkHlmN9JWgXVz7w==", - "dependencies": { - "moment": ">= 2.9.0" - }, - "engines": { - "node": "*" - } - }, "node_modules/morgan": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz", @@ -29673,15 +29641,6 @@ "integrity": "sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==", "dev": true }, - "@types/moment-timezone": { - "version": "0.5.30", - "resolved": "https://registry.npmjs.org/@types/moment-timezone/-/moment-timezone-0.5.30.tgz", - "integrity": "sha512-aDVfCsjYnAQaV/E9Qc24C5Njx1CoDjXsEgkxtp9NyXDpYu4CCbmclb6QhWloS9UTU/8YROUEEdEkWI0D7DxnKg==", - "dev": true, - "requires": { - "moment-timezone": "*" - } - }, "@types/ms": { "version": "0.7.31", "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz", @@ -38587,19 +38546,6 @@ } } }, - "moment": { - "version": "2.29.4", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", - "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==" - }, - "moment-timezone": { - "version": "0.5.39", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.39.tgz", - "integrity": "sha512-hoB6suq4ISDj7BDgctiOy6zljBsdYT0++0ZzZm9rtxIvJhIbQ3nmbgSWe7dNFGurl6/7b1OUkHlmN9JWgXVz7w==", - "requires": { - "moment": ">= 2.9.0" - } - }, "morgan": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz", diff --git a/package.json b/package.json index b86d75403..cf87d8532 100644 --- a/package.json +++ b/package.json @@ -84,8 +84,6 @@ "humanize-duration": "3.28.0", "lodash-es": "4.17.21", "luxon": "3.2.1", - "moment": "2.29.4", - "moment-timezone": "0.5.39", "object-hash": "2.2.0", "rxjs": "^7.5.7", "scroll-into-view-if-needed": "2.2.28", @@ -118,7 +116,6 @@ "@types/jasminewd2": "2.0.6", "@types/lodash-es": "4.17.4", "@types/luxon": "3.2.0", - "@types/moment-timezone": "0.5.30", "@types/object-hash": "2.1.0", "@types/uuid": "^9.0.0", "@typescript-eslint/eslint-plugin": "^5.44.0", diff --git a/projects/angular/directives/ui-dateformat/src/ui-dateformat.directive.luxon.spec.ts b/projects/angular/directives/ui-dateformat/src/ui-dateformat.directive.luxon.spec.ts deleted file mode 100644 index 3dc165c30..000000000 --- a/projects/angular/directives/ui-dateformat/src/ui-dateformat.directive.luxon.spec.ts +++ /dev/null @@ -1,531 +0,0 @@ -import { BehaviorSubject } from 'rxjs'; - -import { - Component, - ViewChild, -} from '@angular/core'; -import { - ComponentFixture, - discardPeriodicTasks, - fakeAsync, - TestBed, - tick, - waitForAsync, -} from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; - -import { - DateTime, - DateTimeFormatOptions, - Settings, -} from 'luxon'; -import { USE_LUXON } from '@uipath/angular/utilities'; -import { - DisplayType, - IDateFormatOptions, - resolveTimezone, - UiDateFormatDirective, - UI_DATEFORMAT_OPTIONS, -} from './ui-dateformat.directive'; - -const defaultDateFormat = DateTime.DATETIME_SHORT; -const referenceFormatLongDateFormatKey = DateTime.DATETIME_FULL; -const updatedTimezone = 'Europe/London'; - -@Component({ - selector: `ui-host-component`, - template: ``, -}) -class TestHostComponent { - date?: Date | string; - dateFormat?: DateTimeFormatOptions; - timezone?: string; - contentType?: DisplayType; - titleType?: DisplayType; - - @ViewChild(UiDateFormatDirective, { - static: true, - }) - uiDateFormat!: UiDateFormatDirective; -} - -describe('Directive: UiDateFormat with luxon', () => { - let fixture: ComponentFixture; - let component: TestHostComponent; - let referenceDate: Date; - let inputDate: DateTime; - let options: IDateFormatOptions; - const beforeConfig = (optionsConfig: IDateFormatOptions) => { - options = optionsConfig; - - Settings.defaultLocale = 'en'; - - inputDate = DateTime - .now() - .setZone(resolveTimezone(options)); - referenceDate = inputDate.toJSDate(); - - TestBed.configureTestingModule({ - declarations: [ - UiDateFormatDirective, - TestHostComponent, - ], - providers: [ - { - provide: UI_DATEFORMAT_OPTIONS, - useValue: options, - }, - { - provide: USE_LUXON, - useValue: true, - }, - ], - }); - }; - - afterEach(() => { - fixture.destroy(); - Settings.defaultLocale = 'en'; - }); - - describe('Generic injection token:', () => { - beforeEach(waitForAsync(() => beforeConfig({ - timezone: 'Europe/Bucharest', - redraw$: new BehaviorSubject(void 0), - format: defaultDateFormat, - }))); - - it('should create', () => { - fixture = TestBed.createComponent(TestHostComponent); - - component = fixture.componentInstance; - - expect(component.uiDateFormat).toBeDefined(); - }); - - it('should format the absolute date in the default format', () => { - fixture = TestBed.createComponent(TestHostComponent); - - component = fixture.componentInstance; - component.date = referenceDate; - - fixture.detectChanges(); - - const formattedDateText = fixture - .debugElement - .query( - By.css('ui-dateformat'), - ) - .nativeElement - .innerText - .trim(); - - expect(formattedDateText).toEqual(inputDate.toLocaleString(defaultDateFormat)); - }); - - it('should format the absolute date in the specified format', () => { - fixture = TestBed - .overrideComponent(TestHostComponent, { - set: { - template: ``, - }, - }) - .createComponent(TestHostComponent); - - component = fixture.componentInstance; - component.date = referenceDate; - component.dateFormat = referenceFormatLongDateFormatKey; - - fixture.detectChanges(); - - const formattedDateText = fixture - .debugElement - .query( - By.css('ui-dateformat'), - ) - .nativeElement - .innerText - .trim(); - - expect(formattedDateText).toEqual(inputDate.toLocaleString(referenceFormatLongDateFormatKey)); - }); - - it('should format the absolute date in the specified timezone', () => { - fixture = TestBed - .overrideComponent(TestHostComponent, { - set: { - template: ``, - }, - }) - .createComponent(TestHostComponent); - - // Update the input date to the new timezone and check if UiDateFormatDirective returns the same date. - inputDate = DateTime.fromJSDate(referenceDate, { - zone: updatedTimezone, - }); - - component = fixture.componentInstance; - component.date = referenceDate; - component.dateFormat = referenceFormatLongDateFormatKey; - component.timezone = updatedTimezone; - - fixture.detectChanges(); - - const formattedDateText = fixture - .debugElement - .query( - By.css('ui-dateformat'), - ) - .nativeElement - .innerText - .trim(); - - expect(formattedDateText).toEqual(inputDate.toLocaleString(referenceFormatLongDateFormatKey)); - }); - - it('should show the relative time', () => { - fixture = TestBed - .overrideComponent(TestHostComponent, { - set: { - template: ``, - }, - }) - .createComponent(TestHostComponent); - - component = fixture.componentInstance; - component.date = inputDate.minus({ minutes: 2 }).toJSDate(); - - fixture.detectChanges(); - - const formattedDateText = fixture - .debugElement - .query( - By.css('ui-dateformat'), - ) - .nativeElement - .innerText - .trim(); - - expect(formattedDateText).toContain('2 minutes ago'); - }); - - it('should show the relative time as tooltip', () => { - fixture = TestBed - .overrideComponent(TestHostComponent, { - set: { - template: ``, - }, - }) - .createComponent(TestHostComponent); - - component = fixture.componentInstance; - component.date = inputDate.minus({ minutes: 2 }).toJSDate(); - - fixture.detectChanges(); - - const formattedDateText = fixture - .debugElement - .query( - By.css('ui-dateformat'), - ) - .nativeElement - .dataset.title; - - expect(formattedDateText).toContain('2 minutes ago'); - }); - - it('should update the relative time when enough time elapses', fakeAsync(() => { - fixture = TestBed - .overrideComponent(TestHostComponent, { - set: { - template: ``, - }, - }) - .createComponent(TestHostComponent); - - component = fixture.componentInstance; - component.date = inputDate.minus({ seconds: 30 }).toJSDate(); - - fixture.detectChanges(); - - const textElement = fixture - .debugElement - .query( - By.css('ui-dateformat'), - ) - .nativeElement; - - expect(textElement.innerText.trim()).toContain('30 seconds ago'); - - tick(30000); - fixture.detectChanges(); - - expect(textElement.innerText.trim()).toContain('1 minute ago'); - discardPeriodicTasks(); - })); - - it('should update the absolute date format when the locale is changed', () => { - fixture = TestBed - .overrideComponent(TestHostComponent, { - set: { - template: ``, - }, - }) - .createComponent(TestHostComponent); - - component = fixture.componentInstance; - component.date = referenceDate; - component.dateFormat = referenceFormatLongDateFormatKey; - - fixture.detectChanges(); - - Settings.defaultLocale = 'ja'; - (options.redraw$ as BehaviorSubject).next(); - - fixture.detectChanges(); - - const textElement = fixture - .debugElement - .query( - By.css('ui-dateformat'), - ) - .nativeElement; - - const expectedDateText = inputDate.toLocaleString( - referenceFormatLongDateFormatKey, - { - locale: 'ja', - }, - ); - - expect(textElement.innerText.trim()).toEqual(expectedDateText); - expect(textElement.dataset.title.trim()).toEqual(textElement.textContent.trim()); - }); - - it('should update the relative time format when the locale is changed', () => { - fixture = TestBed - .overrideComponent(TestHostComponent, { - set: { - template: ``, - }, - }) - .createComponent(TestHostComponent); - - component = fixture.componentInstance; - component.date = inputDate.minus({ seconds: 30 }).toJSDate(); - - fixture.detectChanges(); - - Settings.defaultLocale = 'ja'; - (options.redraw$ as BehaviorSubject).next(); - - fixture.detectChanges(); - - const textElement = fixture - .debugElement - .query( - By.css('ui-dateformat'), - ) - .nativeElement; - - expect(textElement.innerText.trim()).toContain('30 秒前'); - expect(textElement.dataset.title).toContain('30 秒前'); - }); - - it('should return the input when it is not a Date object', () => { - fixture = TestBed.createComponent(TestHostComponent); - - const inputString = 'not a Date object'; - - component = fixture.componentInstance; - component.date = inputString; - - fixture.detectChanges(); - - const formattedDateText = fixture - .debugElement - .query( - By.css('ui-dateformat'), - ) - .nativeElement - .innerText - .trim(); - - expect(formattedDateText).toBe(inputString); - }); - - it('should update the shown text when contentType changes', () => { - fixture = TestBed - .overrideComponent(TestHostComponent, { - set: { - template: ``, - }, - }) - .createComponent(TestHostComponent); - - const inputJSDate = inputDate.minus({ seconds: 30 }).toJSDate(); - const expectedAbsoluteDate = DateTime.fromJSDate(inputJSDate) - .setZone(inputDate.zone) - .toLocaleString(defaultDateFormat); - - component = fixture.componentInstance; - component.date = inputJSDate; - - const textElement = fixture - .debugElement - .query( - By.css('ui-dateformat'), - ) - .nativeElement; - - // Firstly, check that the date is shown in absolute format. - component.contentType = 'absolute'; - - fixture.detectChanges(); - - expect(textElement.innerText.trim()).toEqual(expectedAbsoluteDate); - - // Secondly, check that the format switches to relative when the property changes. - component.contentType = 'relative'; - - fixture.detectChanges(); - - expect(textElement.innerText.trim()).toContain('30 seconds ago'); - - // Lastly, check that changing from relative to absolute formats the text correctly. - component.contentType = 'absolute'; - - fixture.detectChanges(); - - expect(textElement.innerText.trim()).toEqual(expectedAbsoluteDate); - }); - - it('should update the tooltip when titleType changes', () => { - fixture = TestBed - .overrideComponent(TestHostComponent, { - set: { - template: ``, - }, - }) - .createComponent(TestHostComponent); - - const inputJSDate = inputDate.minus({ seconds: 30 }).toJSDate(); - const expectedAbsoluteDate = DateTime.fromJSDate(inputJSDate) - .setZone(inputDate.zone) - .toLocaleString(defaultDateFormat); - - component = fixture.componentInstance; - component.date = inputJSDate; - - const textElement = fixture - .debugElement - .query( - By.css('ui-dateformat'), - ) - .nativeElement; - - // Firstly, check that the date is shown in absolute format. - component.titleType = 'absolute'; - - fixture.detectChanges(); - - expect(textElement.dataset.title).toEqual(expectedAbsoluteDate); - - // Secondly, check that the format switches to relative when the property changes. - component.titleType = 'relative'; - - fixture.detectChanges(); - - expect(textElement.dataset.title).toContain('30 seconds ago'); - - // Lastly, check that changing from relative to absolute formats the text correctly. - component.titleType = 'absolute'; - - fixture.detectChanges(); - - expect(textElement.dataset.title).toEqual(expectedAbsoluteDate); - }); - - it('should call markForCheck if the date input value changes', fakeAsync(() => { - fixture = TestBed.createComponent(TestHostComponent); - - component = fixture.componentInstance; - const changeDetectorRef = (component.uiDateFormat as any)._cd; - const markForCheckSpy = spyOn(changeDetectorRef, 'markForCheck').and.callThrough(); - - const now = Date.now(); - - expect(component.date).toEqual(undefined); - - component.date = new Date(now); - fixture.detectChanges(); - - component.date = new Date(now); - fixture.detectChanges(); - - const stringDate = '09/21/2022'; - component.date = stringDate; - fixture.detectChanges(); - - component.date = stringDate; - fixture.detectChanges(); - - component.date = undefined; - fixture.detectChanges(); - - component.date = undefined; - tick(0); - fixture.detectChanges(); - - expect(markForCheckSpy).toHaveBeenCalledTimes(1); - discardPeriodicTasks(); - })); - }); - - describe('Configure inputs by setting injection token properties', () => { - beforeEach(waitForAsync(() => beforeConfig({ - timezone: 'Europe/Bucharest', - redraw$: new BehaviorSubject(void 0), - titleType: 'relative', - contentType: 'relative', - format: DateTime.DATETIME_SHORT_WITH_SECONDS, - }))); - - it('should show explicit date', () => { - fixture = TestBed - .overrideComponent(TestHostComponent, { - set: { - template: ``, - }, - }) - .createComponent(TestHostComponent); - - component = fixture.componentInstance; - component.date = inputDate.minus({ minutes: 2 }).toJSDate(); - - fixture.detectChanges(); - const dateformatElement = fixture - .debugElement - .query( - By.css('ui-dateformat'), - ) - .nativeElement; - const formattedDateText = dateformatElement.dataset.title; - const contentText = dateformatElement.innerText; - expect(formattedDateText).toContain('2 minutes ago'); - expect(component.uiDateFormat.dateFormat).toEqual(DateTime.DATETIME_SHORT_WITH_SECONDS); - expect(contentText).toEqual('2 minutes ago'); - }); - }); -}); diff --git a/projects/angular/directives/ui-dateformat/src/ui-dateformat.directive.spec.ts b/projects/angular/directives/ui-dateformat/src/ui-dateformat.directive.spec.ts index 755a71ca1..eee6ca45d 100644 --- a/projects/angular/directives/ui-dateformat/src/ui-dateformat.directive.spec.ts +++ b/projects/angular/directives/ui-dateformat/src/ui-dateformat.directive.spec.ts @@ -1,4 +1,8 @@ -import * as moment from 'moment'; +import { + DateTime, + DateTimeFormatOptions, + Settings, +} from 'luxon'; import { BehaviorSubject } from 'rxjs'; import { @@ -23,10 +27,8 @@ import { UI_DATEFORMAT_OPTIONS, } from './ui-dateformat.directive'; -const defaultDateFormat = 'L LTS'; -const referenceFormatLongDateFormatKey = 'LLLL'; -const referenceFormat = 'dddd, MMMM Do, YYYY LT'; -const updatedReferenceFormat = 'YYYY年M月D日 dddd LT'; +const defaultDateFormat = DateTime.DATETIME_SHORT; +const referenceFormatLongDateFormatKey = DateTime.DATETIME_FULL; const updatedTimezone = 'Europe/London'; @Component({ @@ -35,7 +37,7 @@ const updatedTimezone = 'Europe/London'; }) class TestHostComponent { date?: Date | string; - dateFormat?: string; + dateFormat?: DateTimeFormatOptions; timezone?: string; contentType?: DisplayType; titleType?: DisplayType; @@ -50,37 +52,17 @@ describe('Directive: UiDateFormat', () => { let fixture: ComponentFixture; let component: TestHostComponent; let referenceDate: Date; - let momentInputDate: moment.Moment; + let inputDate: DateTime; let options: IDateFormatOptions; const beforeConfig = (optionsConfig: IDateFormatOptions) => { options = optionsConfig; - moment.updateLocale('en', { - longDateFormat: { - LT: 'h:mm A', - LTS: 'h:mm:ss A', - L: 'MM/DD/YYYY', - LL: 'MMMM D', - LLL: 'MMMM D, LT', - LLLL: referenceFormat, - }, - }); - - moment.updateLocale('ja', { - longDateFormat: { - LT: 'HH時mm分', - LTS: 'HH時mm分ss秒', - L: 'YYYY年M月D日', - LL: 'M月D日', - LLL: 'M月D日 LT', - LLLL: updatedReferenceFormat, - }, - }); - moment.locale('en'); + Settings.defaultLocale = 'en'; - momentInputDate = moment() - .tz(resolveTimezone(options)); - referenceDate = momentInputDate.toDate(); + inputDate = DateTime + .now() + .setZone(resolveTimezone(options)); + referenceDate = inputDate.toJSDate(); TestBed.configureTestingModule({ declarations: [ @@ -98,13 +80,14 @@ describe('Directive: UiDateFormat', () => { afterEach(() => { fixture.destroy(); - moment.locale('en'); + Settings.defaultLocale = 'en'; }); describe('Generic injection token:', () => { beforeEach(waitForAsync(() => beforeConfig({ timezone: 'Europe/Bucharest', redraw$: new BehaviorSubject(void 0), + format: defaultDateFormat, }))); it('should create', () => { @@ -132,17 +115,7 @@ describe('Directive: UiDateFormat', () => { .innerText .trim(); - const momentOutputDate = moment.tz( - formattedDateText, - defaultDateFormat, - resolveTimezone(options), - ); - - expect(momentOutputDate.day()).toEqual(momentInputDate.day()); - expect(momentOutputDate.month()).toEqual(momentInputDate.month()); - expect(momentOutputDate.year()).toEqual(momentInputDate.year()); - expect(momentOutputDate.hour()).toEqual(momentInputDate.hour()); - expect(momentOutputDate.minute()).toEqual(momentInputDate.minute()); + expect(formattedDateText).toEqual(inputDate.toLocaleString(defaultDateFormat)); }); it('should format the absolute date in the specified format', () => { @@ -170,17 +143,7 @@ describe('Directive: UiDateFormat', () => { .innerText .trim(); - const momentOutputDate = moment.tz( - formattedDateText, - referenceFormat, - resolveTimezone(options), - ); - - expect(momentOutputDate.day()).toEqual(momentInputDate.day()); - expect(momentOutputDate.month()).toEqual(momentInputDate.month()); - expect(momentOutputDate.year()).toEqual(momentInputDate.year()); - expect(momentOutputDate.hour()).toEqual(momentInputDate.hour()); - expect(momentOutputDate.minute()).toEqual(momentInputDate.minute()); + expect(formattedDateText).toEqual(inputDate.toLocaleString(referenceFormatLongDateFormatKey)); }); it('should format the absolute date in the specified timezone', () => { @@ -195,8 +158,9 @@ describe('Directive: UiDateFormat', () => { .createComponent(TestHostComponent); // Update the input date to the new timezone and check if UiDateFormatDirective returns the same date. - momentInputDate = moment(referenceDate) - .tz(updatedTimezone); + inputDate = DateTime.fromJSDate(referenceDate, { + zone: updatedTimezone, + }); component = fixture.componentInstance; component.date = referenceDate; @@ -214,17 +178,7 @@ describe('Directive: UiDateFormat', () => { .innerText .trim(); - const momentOutputDate = moment.tz( - formattedDateText, - referenceFormat, - updatedTimezone, - ); - - expect(momentOutputDate.day()).toEqual(momentInputDate.day()); - expect(momentOutputDate.month()).toEqual(momentInputDate.month()); - expect(momentOutputDate.year()).toEqual(momentInputDate.year()); - expect(momentOutputDate.hour()).toEqual(momentInputDate.hour()); - expect(momentOutputDate.minute()).toEqual(momentInputDate.minute()); + expect(formattedDateText).toEqual(inputDate.toLocaleString(referenceFormatLongDateFormatKey)); }); it('should show the relative time', () => { @@ -238,7 +192,7 @@ describe('Directive: UiDateFormat', () => { .createComponent(TestHostComponent); component = fixture.componentInstance; - component.date = momentInputDate.subtract(2, 'minutes').toDate(); + component.date = inputDate.minus({ minutes: 2 }).toJSDate(); fixture.detectChanges(); @@ -265,7 +219,7 @@ describe('Directive: UiDateFormat', () => { .createComponent(TestHostComponent); component = fixture.componentInstance; - component.date = momentInputDate.subtract(2, 'minutes').toDate(); + component.date = inputDate.minus({ minutes: 2 }).toJSDate(); fixture.detectChanges(); @@ -291,7 +245,7 @@ describe('Directive: UiDateFormat', () => { .createComponent(TestHostComponent); component = fixture.componentInstance; - component.date = momentInputDate.subtract(30, 'seconds').toDate(); + component.date = inputDate.minus({ seconds: 30 }).toJSDate(); fixture.detectChanges(); @@ -302,12 +256,12 @@ describe('Directive: UiDateFormat', () => { ) .nativeElement; - expect(textElement.innerText.trim()).toContain('a few seconds ago'); + expect(textElement.innerText.trim()).toContain('30 seconds ago'); tick(30000); fixture.detectChanges(); - expect(textElement.innerText.trim()).toContain('a minute ago'); + expect(textElement.innerText.trim()).toContain('1 minute ago'); discardPeriodicTasks(); })); @@ -327,7 +281,7 @@ describe('Directive: UiDateFormat', () => { fixture.detectChanges(); - moment.locale('ja'); + Settings.defaultLocale = 'ja'; (options.redraw$ as BehaviorSubject).next(); fixture.detectChanges(); @@ -339,17 +293,14 @@ describe('Directive: UiDateFormat', () => { ) .nativeElement; - const momentOutputDate = moment.tz( - textElement.innerText.trim(), - updatedReferenceFormat, - resolveTimezone(options), + const expectedDateText = inputDate.toLocaleString( + referenceFormatLongDateFormatKey, + { + locale: 'ja', + }, ); - expect(momentOutputDate.day()).toEqual(momentInputDate.day()); - expect(momentOutputDate.month()).toEqual(momentInputDate.month()); - expect(momentOutputDate.year()).toEqual(momentInputDate.year()); - expect(momentOutputDate.hour()).toEqual(momentInputDate.hour()); - expect(momentOutputDate.minute()).toEqual(momentInputDate.minute()); + expect(textElement.innerText.trim()).toEqual(expectedDateText); expect(textElement.dataset.title.trim()).toEqual(textElement.textContent.trim()); }); @@ -365,11 +316,11 @@ describe('Directive: UiDateFormat', () => { .createComponent(TestHostComponent); component = fixture.componentInstance; - component.date = momentInputDate.subtract(30, 'seconds').toDate(); + component.date = inputDate.minus({ seconds: 30 }).toJSDate(); fixture.detectChanges(); - moment.locale('ja'); + Settings.defaultLocale = 'ja'; (options.redraw$ as BehaviorSubject).next(); fixture.detectChanges(); @@ -381,8 +332,8 @@ describe('Directive: UiDateFormat', () => { ) .nativeElement; - expect(textElement.innerText.trim()).toContain('数秒前'); - expect(textElement.dataset.title).toContain('数秒前'); + expect(textElement.innerText.trim()).toContain('30 秒前'); + expect(textElement.dataset.title).toContain('30 秒前'); }); it('should return the input when it is not a Date object', () => { @@ -417,8 +368,13 @@ describe('Directive: UiDateFormat', () => { }) .createComponent(TestHostComponent); + const inputJSDate = inputDate.minus({ seconds: 30 }).toJSDate(); + const expectedAbsoluteDate = DateTime.fromJSDate(inputJSDate) + .setZone(inputDate.zone) + .toLocaleString(defaultDateFormat); + component = fixture.componentInstance; - component.date = momentInputDate.subtract(30, 'seconds').toDate(); + component.date = inputJSDate; const textElement = fixture .debugElement @@ -432,41 +388,21 @@ describe('Directive: UiDateFormat', () => { fixture.detectChanges(); - let momentOutputDate = moment.tz( - textElement.innerText.trim(), - defaultDateFormat, - resolveTimezone(options), - ); - - expect(momentOutputDate.day()).toEqual(momentInputDate.day()); - expect(momentOutputDate.month()).toEqual(momentInputDate.month()); - expect(momentOutputDate.year()).toEqual(momentInputDate.year()); - expect(momentOutputDate.hour()).toEqual(momentInputDate.hour()); - expect(momentOutputDate.minute()).toEqual(momentInputDate.minute()); + expect(textElement.innerText.trim()).toEqual(expectedAbsoluteDate); // Secondly, check that the format switches to relative when the property changes. component.contentType = 'relative'; fixture.detectChanges(); - expect(textElement.innerText.trim()).toContain('a few seconds ago'); + expect(textElement.innerText.trim()).toContain('30 seconds ago'); // Lastly, check that changing from relative to absolute formats the text correctly. component.contentType = 'absolute'; fixture.detectChanges(); - momentOutputDate = moment.tz( - textElement.innerText.trim(), - defaultDateFormat, - resolveTimezone(options), - ); - - expect(momentOutputDate.day()).toEqual(momentInputDate.day()); - expect(momentOutputDate.month()).toEqual(momentInputDate.month()); - expect(momentOutputDate.year()).toEqual(momentInputDate.year()); - expect(momentOutputDate.hour()).toEqual(momentInputDate.hour()); - expect(momentOutputDate.minute()).toEqual(momentInputDate.minute()); + expect(textElement.innerText.trim()).toEqual(expectedAbsoluteDate); }); it('should update the tooltip when titleType changes', () => { @@ -479,8 +415,13 @@ describe('Directive: UiDateFormat', () => { }) .createComponent(TestHostComponent); + const inputJSDate = inputDate.minus({ seconds: 30 }).toJSDate(); + const expectedAbsoluteDate = DateTime.fromJSDate(inputJSDate) + .setZone(inputDate.zone) + .toLocaleString(defaultDateFormat); + component = fixture.componentInstance; - component.date = momentInputDate.subtract(30, 'seconds').toDate(); + component.date = inputJSDate; const textElement = fixture .debugElement @@ -494,41 +435,21 @@ describe('Directive: UiDateFormat', () => { fixture.detectChanges(); - let momentOutputDate = moment.tz( - textElement.dataset.title, - defaultDateFormat, - resolveTimezone(options), - ); - - expect(momentOutputDate.day()).toEqual(momentInputDate.day()); - expect(momentOutputDate.month()).toEqual(momentInputDate.month()); - expect(momentOutputDate.year()).toEqual(momentInputDate.year()); - expect(momentOutputDate.hour()).toEqual(momentInputDate.hour()); - expect(momentOutputDate.minute()).toEqual(momentInputDate.minute()); + expect(textElement.dataset.title).toEqual(expectedAbsoluteDate); // Secondly, check that the format switches to relative when the property changes. component.titleType = 'relative'; fixture.detectChanges(); - expect(textElement.dataset.title).toContain('a few seconds ago'); + expect(textElement.dataset.title).toContain('30 seconds ago'); // Lastly, check that changing from relative to absolute formats the text correctly. component.titleType = 'absolute'; fixture.detectChanges(); - momentOutputDate = moment.tz( - textElement.dataset.title, - defaultDateFormat, - resolveTimezone(options), - ); - - expect(momentOutputDate.day()).toEqual(momentInputDate.day()); - expect(momentOutputDate.month()).toEqual(momentInputDate.month()); - expect(momentOutputDate.year()).toEqual(momentInputDate.year()); - expect(momentOutputDate.hour()).toEqual(momentInputDate.hour()); - expect(momentOutputDate.minute()).toEqual(momentInputDate.minute()); + expect(textElement.dataset.title).toEqual(expectedAbsoluteDate); }); it('should call markForCheck if the date input value changes', fakeAsync(() => { @@ -573,7 +494,7 @@ describe('Directive: UiDateFormat', () => { redraw$: new BehaviorSubject(void 0), titleType: 'relative', contentType: 'relative', - format: 'MM/DD/YYYY H:mm:ss.SSS', + format: DateTime.DATETIME_SHORT_WITH_SECONDS, }))); it('should show explicit date', () => { @@ -586,7 +507,7 @@ describe('Directive: UiDateFormat', () => { .createComponent(TestHostComponent); component = fixture.componentInstance; - component.date = momentInputDate.subtract(2, 'minutes').toDate(); + component.date = inputDate.minus({ minutes: 2 }).toJSDate(); fixture.detectChanges(); const dateformatElement = fixture @@ -598,7 +519,7 @@ describe('Directive: UiDateFormat', () => { const formattedDateText = dateformatElement.dataset.title; const contentText = dateformatElement.innerText; expect(formattedDateText).toContain('2 minutes ago'); - expect(component.uiDateFormat.dateFormat).toEqual('MM/DD/YYYY H:mm:ss.SSS'); + expect(component.uiDateFormat.dateFormat).toEqual(DateTime.DATETIME_SHORT_WITH_SECONDS); expect(contentText).toEqual('2 minutes ago'); }); }); diff --git a/projects/angular/directives/ui-dateformat/src/ui-dateformat.directive.ts b/projects/angular/directives/ui-dateformat/src/ui-dateformat.directive.ts index bb438fb91..2d86f9165 100644 --- a/projects/angular/directives/ui-dateformat/src/ui-dateformat.directive.ts +++ b/projects/angular/directives/ui-dateformat/src/ui-dateformat.directive.ts @@ -1,10 +1,7 @@ -import 'moment-timezone'; - import { DateTime, DateTimeFormatOptions, } from 'luxon'; -import moment from 'moment'; import { interval, merge, @@ -30,7 +27,6 @@ import { Renderer2, } from '@angular/core'; import { UiFormatDirective } from '@uipath/angular/directives/internal'; -import { USE_LUXON } from '@uipath/angular/utilities'; /** * The date format display type options. @@ -67,8 +63,7 @@ export interface IDateFormatOptions { */ titleType?: DisplayType; /** - * Overwrites the default dateformat used by moment.js. - * When supplied Luxon formatting options, Luxon will be used instead of moment.js. + * Overwrites the default dateformat. * */ format?: string | DateTimeFormatOptions; @@ -102,15 +97,6 @@ export const resolveTimezone = (options: IDateFormatOptions) => { * A directive that formats a given `Date` input in a `relative` or `absolute` format. * * Depends On: - * - [moment](https://www.npmjs.com/package/moment) - * - [moment-timezone](https://www.npmjs.com/package/moment-timezone) - * - * In order to reduce bundle sizes, we strongly recommend using the following webpack plugins: - * - [moment-locales-webpack-plugin](https://www.npmjs.com/package/moment-locales-webpack-plugin) - * - [moment-timezone-data-webpack-plugin](https://www.npmjs.com/package/moment-timezone-data-webpack-plugin) - * - * Optionally, you can opt-in to use Luxon instead of Moment. - * Depends On: * - [luxon](https://www.npmjs.com/package/luxon) * - [humanize-duration](https://www.npmjs.com/package/humanize-duration) * @@ -179,7 +165,6 @@ export class UiDateFormatDirective extends UiFormatDirective { return this._date; } /** - * The 'moment' format defaults to 'L LTS'. * The `luxon` format defaults to `DateTime.DATETIME_SHORT_WITH_SECONDS. * */ @@ -192,11 +177,8 @@ export class UiDateFormatDirective extends UiFormatDirective { if (!this.date) { return ''; } if (!(this.date instanceof Date)) { return this.date; } - const relativeTime = this._useLuxon - ? DateTime.fromJSDate(this.date) - .toRelative() - : moment(this.date) - .fromNow(); + const relativeTime = DateTime.fromJSDate(this.date) + .toRelative(); return relativeTime ?? ''; } @@ -205,15 +187,14 @@ export class UiDateFormatDirective extends UiFormatDirective { if (!this.date) { return ''; } if (!(this.date instanceof Date)) { return this.date; } - let absoluteTime; + const time = DateTime + .fromJSDate(this.date, { + zone: this.timezone ?? resolveTimezone(this._options), + }); - if (this._useLuxon) { - absoluteTime = this._luxonAbsoluteTime(this.date); - } else if (this._isStringFormat(this.dateFormat)) { - absoluteTime = moment(this.date) - .tz(this.timezone ?? resolveTimezone(this._options)) - .format(this.dateFormat); - } + const absoluteTime = this._isStringFormat(this.dateFormat) + ? time.toFormat(this.dateFormat) + : time.toLocaleString(this.dateFormat); return absoluteTime ?? ''; } @@ -235,16 +216,13 @@ export class UiDateFormatDirective extends UiFormatDirective { private _zone: NgZone, renderer: Renderer2, elementRef: ElementRef, - @Inject(USE_LUXON) - @Optional() - private _useLuxon?: boolean, ) { super( renderer, elementRef, ); - const defaultFormat = this._useLuxon ? DateTime.DATETIME_SHORT_WITH_SECONDS : 'L LTS'; + const defaultFormat = DateTime.DATETIME_SHORT_WITH_SECONDS; this._options = _options || {}; this.dateFormat = this._options.format ?? defaultFormat; @@ -326,15 +304,4 @@ export class UiDateFormatDirective extends UiFormatDirective { return value !== compareValue; }; - - private _luxonAbsoluteTime(date: Date) { - const time = DateTime - .fromJSDate(date, { - zone: this.timezone ?? resolveTimezone(this._options), - }); - - return this._isStringFormat(this.dateFormat) - ? time.toFormat(this.dateFormat) - : time.toLocaleString(this.dateFormat); - } } diff --git a/projects/angular/directives/ui-secondformat/src/ui-secondformat.directive.luxon.spec.ts b/projects/angular/directives/ui-secondformat/src/ui-secondformat.directive.luxon.spec.ts deleted file mode 100644 index 6d6388ae5..000000000 --- a/projects/angular/directives/ui-secondformat/src/ui-secondformat.directive.luxon.spec.ts +++ /dev/null @@ -1,164 +0,0 @@ -import { - BehaviorSubject, - firstValueFrom, -} from 'rxjs'; - -import { - Component, - ViewChild, -} from '@angular/core'; -import { - ComponentFixture, - TestBed, - waitForAsync, -} from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; - -import { Settings } from 'luxon'; -import { USE_LUXON } from '@uipath/angular/utilities'; -import { - ISecondFormatOptions, - UiSecondFormatDirective, - UI_SECONDFORMAT_OPTIONS, -} from './ui-secondformat.directive'; -import { UiSecondFormatModule } from './ui-secondformat.module'; - -@Component({ - selector: `ui-host-component`, - template: ``, -}) -class TestHostComponent { - seconds?: number; - - @ViewChild(UiSecondFormatDirective, { - static: true, - }) - uiSecondFormat!: UiSecondFormatDirective; -} - -const MINUTE = 60; -const HOUR = 60 * MINUTE; -const DAY = 24 * HOUR; - -describe('Directive: UiSecondFormat with luxon', () => { - let fixture: ComponentFixture; - let component: TestHostComponent; - const options: ISecondFormatOptions = { - redraw$: new BehaviorSubject(void 0), - }; - - beforeEach(waitForAsync(() => { - Settings.defaultLocale = 'en'; - - TestBed.configureTestingModule({ - imports: [ - UiSecondFormatModule, - ], - declarations: [ - TestHostComponent, - ], - providers: [ - { - provide: UI_SECONDFORMAT_OPTIONS, - useValue: options, - }, - { - provide: USE_LUXON, - useValue: true, - }, - ], - }); - - fixture = TestBed.createComponent(TestHostComponent); - component = fixture.componentInstance; - })); - - afterEach(() => { - fixture.destroy(); - Settings.defaultLocale = 'en'; - }); - - it('should create', () => { - expect(component.uiSecondFormat).toBeDefined(); - }); - - it('should remain empty for null values', () => { - fixture.detectChanges(); - - const text = fixture.debugElement.query(By.directive(UiSecondFormatDirective)); - - expect(text.nativeElement.innerText).toBe(''); - }); - - describe('language: english', () => { - it('should return correctly display 2 days / PT51H1M3S', async () => { - const days = 2 * DAY; - const hours = 3 * HOUR; - const minutes = 1 * MINUTE; - const seconds = 3; - - component.seconds = days + hours + minutes + seconds; - - fixture.detectChanges(); - - const text = fixture.debugElement.query(By.directive(UiSecondFormatDirective)); - - expect(text.nativeElement.innerText) - .toBe('2 days'); - const tooltip = await firstValueFrom(component.uiSecondFormat.tooltip$); - expect(tooltip).toBe('PT51H1M3S'); - }); - - it('should return correctly a day / PT25H1M1S', async () => { - const days = DAY; - const hours = HOUR; - const minutes = MINUTE; - const seconds = 1; - - component.seconds = days + hours + minutes + seconds; - - fixture.detectChanges(); - - const text = fixture.debugElement.query(By.directive(UiSecondFormatDirective)); - - expect(text.nativeElement.innerText) - .toBe('1 day'); - const tooltip = await firstValueFrom(component.uiSecondFormat.tooltip$); - expect(tooltip).toBe('PT25H1M1S'); - }); - - it('should display 0 seconds / PT0S if the total amount of seconds is 0', async () => { - component.seconds = 0; - - fixture.detectChanges(); - - const text = fixture.debugElement.query(By.directive(UiSecondFormatDirective)); - - expect(text.nativeElement.innerText) - .toBe('0 seconds'); - const tooltip = await firstValueFrom(component.uiSecondFormat.tooltip$); - expect(tooltip).toBe('PT0S'); - }); - }); - - describe('changing languages', () => { - it('should render the ja version after changing', async () => { - Settings.defaultLocale = 'en'; - - component.seconds = 40; - fixture.detectChanges(); - - const text = fixture.debugElement.query(By.directive(UiSecondFormatDirective)); - expect(text.nativeElement.innerText).toBe('40 seconds'); - const enTooltip = await firstValueFrom(component.uiSecondFormat.tooltip$); - - Settings.defaultLocale = 'ja'; - (options.redraw$ as BehaviorSubject).next(); - - fixture.detectChanges(); - expect(text.nativeElement.innerText).toBe('40 秒'); - const jaTooltip = await firstValueFrom(component.uiSecondFormat.tooltip$); - expect(enTooltip).toBe(jaTooltip); - }); - }); -}); diff --git a/projects/angular/directives/ui-secondformat/src/ui-secondformat.directive.spec.ts b/projects/angular/directives/ui-secondformat/src/ui-secondformat.directive.spec.ts index ced6deb65..32bf919c9 100644 --- a/projects/angular/directives/ui-secondformat/src/ui-secondformat.directive.spec.ts +++ b/projects/angular/directives/ui-secondformat/src/ui-secondformat.directive.spec.ts @@ -1,4 +1,4 @@ -import * as moment from 'moment'; +import { Settings } from 'luxon'; import { BehaviorSubject, firstValueFrom, @@ -47,7 +47,7 @@ describe('Directive: UiSecondFormat', () => { }; beforeEach(waitForAsync(() => { - moment.locale('en'); + Settings.defaultLocale = 'en'; TestBed.configureTestingModule({ imports: [ @@ -70,7 +70,7 @@ describe('Directive: UiSecondFormat', () => { afterEach(() => { fixture.destroy(); - moment.locale('en'); + Settings.defaultLocale = 'en'; }); it('should create', () => { @@ -117,12 +117,12 @@ describe('Directive: UiSecondFormat', () => { const text = fixture.debugElement.query(By.directive(UiSecondFormatDirective)); expect(text.nativeElement.innerText) - .toBe('a day'); + .toBe('1 day'); const tooltip = await firstValueFrom(component.uiSecondFormat.tooltip$); expect(tooltip).toBe('PT25H1M1S'); }); - it('should display a few seconds / P0D if the total amount of seconds is 0', async () => { + it('should display 0 seconds / PT0S if the total amount of seconds is 0', async () => { component.seconds = 0; fixture.detectChanges(); @@ -130,28 +130,28 @@ describe('Directive: UiSecondFormat', () => { const text = fixture.debugElement.query(By.directive(UiSecondFormatDirective)); expect(text.nativeElement.innerText) - .toBe('a few seconds'); + .toBe('0 seconds'); const tooltip = await firstValueFrom(component.uiSecondFormat.tooltip$); - expect(tooltip).toBe('P0D'); + expect(tooltip).toBe('PT0S'); }); }); describe('changing languages', () => { it('should render the ja version after changing', async () => { - moment.locale('en'); + Settings.defaultLocale = 'en'; component.seconds = 40; fixture.detectChanges(); const text = fixture.debugElement.query(By.directive(UiSecondFormatDirective)); - expect(text.nativeElement.innerText).toBe('a few seconds'); + expect(text.nativeElement.innerText).toBe('40 seconds'); const enTooltip = await firstValueFrom(component.uiSecondFormat.tooltip$); - moment.locale('ja'); + Settings.defaultLocale = 'ja'; (options.redraw$ as BehaviorSubject).next(); fixture.detectChanges(); - expect(text.nativeElement.innerText).toBe('数秒'); + expect(text.nativeElement.innerText).toBe('40 秒'); const jaTooltip = await firstValueFrom(component.uiSecondFormat.tooltip$); expect(enTooltip).toBe(jaTooltip); }); diff --git a/projects/angular/directives/ui-secondformat/src/ui-secondformat.directive.ts b/projects/angular/directives/ui-secondformat/src/ui-secondformat.directive.ts index 1e82f25f7..67bcd4546 100644 --- a/projects/angular/directives/ui-secondformat/src/ui-secondformat.directive.ts +++ b/projects/angular/directives/ui-secondformat/src/ui-secondformat.directive.ts @@ -1,6 +1,5 @@ import humanizeDuration from 'humanize-duration'; import { Duration } from 'luxon'; -import moment from 'moment'; import { BehaviorSubject, merge, @@ -20,7 +19,6 @@ import { Input, Optional, } from '@angular/core'; -import { USE_LUXON } from '@uipath/angular/utilities'; /** * The date format options schema. @@ -45,15 +43,6 @@ export const UI_SECONDFORMAT_OPTIONS = new InjectionToken>('UiS * eg: * For input `61` -> output `1 minute` with the tooltip PT1M1S. * Depends On: - * - [moment](https://www.npmjs.com/package/moment) - * - [moment-timezone](https://www.npmjs.com/package/moment-timezone) - * - * In order to reduce bundle sizes, we strongly recommend using the following webpack plugins: - * - [moment-locales-webpack-plugin](https://www.npmjs.com/package/moment-locales-webpack-plugin) - * - [moment-timezone-data-webpack-plugin](https://www.npmjs.com/package/moment-timezone-data-webpack-plugin) - * - * Optionally, you can opt-in to use Luxon instead of Moment. - * Depends On: * - [luxon](https://www.npmjs.com/package/luxon) * - [humanize-duration](https://www.npmjs.com/package/humanize-duration) * @@ -95,9 +84,6 @@ export class UiSecondFormatDirective { @Inject(UI_SECONDFORMAT_OPTIONS) @Optional() options: ISecondFormatOptions, - @Inject(USE_LUXON) - @Optional() - private _useLuxon?: boolean, ) { options = options || {}; const redraw$ = options.redraw$ || of(null); @@ -124,32 +110,26 @@ export class UiSecondFormatDirective { return null; } - return this._useLuxon - ? Duration.fromObject({ seconds }) - : moment.duration(seconds, 'seconds'); + return Duration.fromObject({ seconds }); }; - private _mapDurationToText = (duration: Duration | moment.Duration | null) => { + private _mapDurationToText = (duration: Duration | null) => { if (duration == null) { return ''; } - return moment.isDuration(duration) - ? duration.humanize() - : humanizeDuration(duration.toMillis(), { + return humanizeDuration(duration.toMillis(), { language: duration.locale, // Max number of units is set to 1 to mimic what moment does largest: 1, }); }; - private _mapDurationToTooltip = (duration: Duration | moment.Duration | null) => { + private _mapDurationToTooltip = (duration: Duration | null) => { if (duration == null) { return ''; } - return moment.isDuration(duration) - ? duration.toISOString() - : duration.shiftTo('hours', 'minutes', 'seconds').toISO(); + return duration.shiftTo('hours', 'minutes', 'seconds').toISO(); }; } diff --git a/projects/angular/package.json b/projects/angular/package.json index 3932a2701..910ebe588 100644 --- a/projects/angular/package.json +++ b/projects/angular/package.json @@ -42,8 +42,6 @@ "humanize-duration": "^3.28.0", "lodash-es": "^4.17.21", "luxon": "^3.2.1", - "moment": "^2.29.1", - "moment-timezone": "^0.5.33", "object-hash": "^2.2.0", "rxjs": "^7.0.1", "scroll-into-view-if-needed": "^2.2.28"