Skip to content

Commit

Permalink
(fix) O3-3595: Use correct per-locale calendar in OpenmrsDatepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
kajambiya authored Jul 15, 2024
1 parent 8a6be5a commit b06664c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/framework/esm-styleguide/src/datepicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import {
FieldError,
} from 'react-aria-components';
import dayjs, { type Dayjs } from 'dayjs';
import { convertToLocaleCalendar, formatDate, getDefaultCalendar, getLocale } from '@openmrs/esm-utils';
import { formatDate, getDefaultCalendar, getLocale } from '@openmrs/esm-utils';
import styles from './datepicker.module.scss';
import { CalendarIcon, CaretDownIcon, CaretUpIcon, ChevronLeftIcon, ChevronRightIcon, WarningIcon } from '../icons';

Expand Down Expand Up @@ -116,11 +116,11 @@ function dateToInternationalizedDate(date: DateInputValue, calendar: CalendarTyp
}

if (date instanceof CalendarDate || date instanceof CalendarDateTime || date instanceof ZonedDateTime) {
return date;
return calendar ? toCalendar(date, calendar) : date;
} else {
const date_ = dayjs(date).toDate();
return calendar
? new CalendarDate(calendar, date_.getFullYear(), date_.getMonth() + 1, date_.getDate())
? toCalendar(new CalendarDate(date_.getFullYear(), date_.getMonth() + 1, date_.getDate()), calendar)
: new CalendarDate(date_.getFullYear(), date_.getMonth() + 1, date_.getDate());
}
}
Expand Down

0 comments on commit b06664c

Please sign in to comment.