This commit is contained in:
Aayush Rohila
2023-10-09 18:20:51 +05:30
parent 5e51f70ea4
commit 600aea74a9
3 changed files with 7 additions and 7 deletions
@@ -22,7 +22,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ContentTestingModule } from '../../../testing/content.testing.module';
import { TranslateModule } from '@ngx-translate/core';
import { DateFnsAdapter } from '@angular/material-date-fns-adapter';
import { endOfDay, endOfToday, isValid, parse, startOfDay } from 'date-fns';
import { endOfDay, endOfToday, isValid, startOfDay } from 'date-fns';
declare let moment: any;
@@ -77,7 +77,7 @@ describe('SearchDateRangeComponent', () => {
fixture.detectChanges();
const inputString = '20-feb-18';
const dateFromInput = parse(inputString, DateFnsUtils.convertMomentToDateFnsFormat(dateFormatFixture), new Date());
const dateFromInput = DateFnsUtils.parseDate(inputString, DateFnsUtils.convertMomentToDateFnsFormat(dateFormatFixture));
expect(isValid(dateFromInput)).toBeTruthy();
@@ -91,7 +91,7 @@ describe('SearchDateRangeComponent', () => {
fixture.detectChanges();
const inputString = '20.f.18';
const dateFromInput = parse(inputString, DateFnsUtils.convertMomentToDateFnsFormat(dateFormatFixture), new Date());
const dateFromInput = DateFnsUtils.parseDate(inputString, DateFnsUtils.convertMomentToDateFnsFormat(dateFormatFixture));
expect(isValid(dateFromInput)).toBeFalsy();
@@ -115,8 +115,8 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
if (this.startValue) {
const splitValue = this.startValue.split('||');
const fromValue = this.dateAdapter.parse(splitValue[0], DateFnsUtils.convertMomentToDateFnsFormat(this.datePickerFormat));
const toValue = this.dateAdapter.parse(splitValue[1], DateFnsUtils.convertMomentToDateFnsFormat(this.datePickerFormat));
const fromValue = this.dateAdapter.parse(splitValue[0], this.datePickerFormat);
const toValue = this.dateAdapter.parse(splitValue[1], this.datePickerFormat);
this.from = new UntypedFormControl(fromValue, validators);
this.to = new UntypedFormControl(toValue, validators);
} else {
@@ -185,11 +185,11 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges, On
}
}
convertMomentDate(date: string) {
convertMomentDate(date: string): string {
return DateFnsUtils.formatDate(new Date(date), FORMAT_DATE_ACTIVITI) + 'T00:00:00.000Z'
}
getTodayDate() {
getTodayDate(): string {
return DateFnsUtils.formatDate(new Date(), FORMAT_DATE_ACTIVITI);
}