@ugandaemr/esm-patient-appointments-app
Version:
Patient appointments microfrontend for the OpenMRS SPA
16 lines (11 loc) • 317 B
text/typescript
export type amPm = "AM" | "PM";
export const convertTime12to24 = (time12h, timeFormat: amPm) => {
let [hours, minutes] = time12h.split(":");
if (hours === "12" && timeFormat === "AM") {
hours = "00";
}
if (timeFormat === "PM") {
hours = parseInt(hours, 10) + 12;
}
return [hours, minutes];
};