Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) O3-3402 Display correct locale date format in view mode #323

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/inputs/date/date.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import FieldValueView from '../../value/view/field-value-view.component';
import RequiredFieldLabel from '../../required-field-label/required-field-label.component';
import styles from './date.scss';
import { useFieldValidationResults } from '../../../hooks/useFieldValidationResults';
import { OpenmrsDatePicker } from '@openmrs/esm-framework';
import { OpenmrsDatePicker, formatDate, formatTime } from '@openmrs/esm-framework';

const locale = window.i18next.language == 'en' ? 'en-GB' : window.i18next.language;
const dateFormatter = new Intl.DateTimeFormat(locale);
Expand Down Expand Up @@ -181,9 +181,9 @@ const DateField: React.FC<FormFieldProps> = ({ question, onChange, handler, prev
};

function getDisplay(date: Date, rendering: string) {
const dateString = date.toLocaleDateString(window.navigator.language);
const dateString = formatDate(date);
if (rendering == 'datetime') {
return `${dateString} ${date.toLocaleTimeString()}`;
return `${dateString} ${formatTime(date)}`;
}
return dateString;
}
Expand Down
Loading