Stop using localized Dates. Ensure we always use UTC dates, as the backend expects/uses UTC.

This commit is contained in:
Tim Donohue
2021-07-01 17:17:53 -05:00
parent 6d13ba42c6
commit 9ee733ea80
5 changed files with 15 additions and 15 deletions

View File

@@ -107,6 +107,6 @@ describe('BrowseByDatePageComponent', () => {
});
it('should create a list of startsWith options with the current year first', () => {
expect(comp.startsWithOptions[0]).toEqual(new Date().getFullYear());
expect(comp.startsWithOptions[0]).toEqual(new Date().getUTCFullYear());
});
});

View File

@@ -92,7 +92,7 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent {
}
}
const options = [];
const currentYear = new Date().getFullYear();
const currentYear = new Date().getUTCFullYear();
const oneYearBreak = Math.floor((currentYear - environment.browseBy.oneYearLimit) / 5) * 5;
const fiveYearBreak = Math.floor((currentYear - environment.browseBy.fiveYearLimit) / 10) * 10;
if (lowerLimit <= fiveYearBreak) {

View File

@@ -57,9 +57,9 @@ export class DsDatePickerComponent extends DynamicFormControlComponent implement
ngOnInit() {
const now = new Date();
this.initialYear = now.getFullYear();
this.initialMonth = now.getMonth() + 1;
this.initialDay = now.getDate();
this.initialYear = now.getUTCFullYear();
this.initialMonth = now.getUTCMonth() + 1;
this.initialDay = now.getUTCDate();
if (this.model && this.model.value !== null) {
const values = this.model.value.toString().split(DS_DATE_PICKER_SEPARATOR);

View File

@@ -56,7 +56,7 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple
/**
* Fallback maximum for the range
*/
max = new Date().getFullYear();
max = new Date().getUTCFullYear();
/**
* The current range of the filter

View File

@@ -244,9 +244,9 @@ export class SubmissionSectionUploadFileEditComponent implements OnChanges {
if (metadataModel.type === DYNAMIC_FORM_CONTROL_TYPE_DATEPICKER) {
const date = new Date(accessCondition[key]);
metadataModel.value = {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate()
year: date.getUTCFullYear(),
month: date.getUTCMonth() + 1,
day: date.getUTCDate()
};
} else {
metadataModel.value = accessCondition[key];
@@ -302,9 +302,9 @@ export class SubmissionSectionUploadFileEditComponent implements OnChanges {
const min = new Date(accessCondition.maxStartDate);
startDateModel.max = {
year: min.getFullYear(),
month: min.getMonth() + 1,
day: min.getDate()
year: min.getUTCFullYear(),
month: min.getUTCMonth() + 1,
day: min.getUTCDate()
};
}
if (accessCondition.hasEndDate) {
@@ -314,9 +314,9 @@ export class SubmissionSectionUploadFileEditComponent implements OnChanges {
const max = new Date(accessCondition.maxEndDate);
endDateModel.max = {
year: max.getFullYear(),
month: max.getMonth() + 1,
day: max.getDate()
year: max.getUTCFullYear(),
month: max.getUTCMonth() + 1,
day: max.getUTCDate()
};
}
}