Skip to content

Commit

Permalink
fix: working list filter runtime error when dd-mm-yyyy format is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
alaa-yahia committed Dec 10, 2024
1 parent 0294f8d commit ec75f9e
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
import moment from 'moment';
import {
convertFromIso8601,
} from '@dhis2/multi-calendar-dates';
Expand All @@ -16,10 +17,18 @@ export function convertIsoToLocalCalendar(isoDate: ?string): string {
if (!isoDate) {
return '';
}

const momentDate = moment(isoDate);
if (!momentDate.isValid()) {
return '';
}

const formattedIsoDate = momentDate.format('YYYY-MM-DD');

const calendar = systemSettingsStore.get().calendar;
const dateFormat = systemSettingsStore.get().dateFormat;

const { year, eraYear, month, day } = convertFromIso8601(isoDate, calendar);
const { year, eraYear, month, day } = convertFromIso8601(formattedIsoDate, calendar);
const localYear = calendar === 'ethiopian' ? eraYear : year;

return dateFormat === 'DD-MM-YYYY'
Expand Down

0 comments on commit ec75f9e

Please sign in to comment.