# O3: Config to set a standard date/time convention throughout App?

**URL:** <https://talk.openmrs.org/t/o3-config-to-set-a-standard-date-time-convention-throughout-app/35726>\
**Category:** Development\
**Tags:** i18n, timezones, o3\
**Created:** [January 26, 2022, 7:35pm UTC](https://talk.openmrs.org/t/o3-config-to-set-a-standard-date-time-convention-throughout-app/35726 "2022-01-26T19:35:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![grace](https://talk.openmrs.org/user_avatar/talk.openmrs.org/grace/32/16942_2.png) [@grace](https://talk.openmrs.org/u/grace)\
**Post date:** [January 26, 2022, 7:35pm UTC](https://talk.openmrs.org/t/o3-config-to-set-a-standard-date-time-convention-throughout-app/35726/1 "2022-01-26T19:35:03Z")

</div>

### Problems

We have 2 time-display problems to address as we build 3.x: (if I ignore timezones 😛 )

1. **We don’t yet have 1 clear standard for date and time display throughout 3.x.** Though we have repeatedly agreed in design conversations that we want to follow [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#General_principles), where today’s date/time could be written as “2022-01-26 23:56” (note the **24 hour** time format). I see this as semi-urgent as we are already having bugs like [O3-1027](https://issues.openmrs.org/browse/O3-1027) where the time “7 **pm** ” is being misleadingly displayed as “07:00”.

2. **Organizations may need to configure that standard** to match their country/region’s policies (e.g. some regions are strict on the YYYY-DD-MM format, for reasons I’ll never understand).

### Proposal

- Have ONE place in O3 config, where the Date/Time format is specified; default is ISO-8601 format
- All 3.x Dates/Times apply that Date/Time format in the UI
- Implementers can configure this **ONE** place to change the format (e.g. to YYYY-DD-MM, 7:00pm etc)

What do folks think of this?

Has anyone encountered a solid real-world use case where you really needed TWO different formats within ONE implementation?

cc @jdick @mksd @bistenes @dennis @mseaton @mogoodrich @pmanko

---

<div class="post-metadata">

**Author:** ![grace](https://talk.openmrs.org/user_avatar/talk.openmrs.org/grace/32/16942_2.png) [@grace](https://talk.openmrs.org/u/grace)\
**Post date:** [January 26, 2022, 7:51pm UTC](https://talk.openmrs.org/t/o3-config-to-set-a-standard-date-time-convention-throughout-app/35726/2 "2022-01-26T19:51:04Z")

</div>

Visual examples of current inconsistency in 3.x app: (e.g. 24hr vs AM/PM;

 ![image](https://talk.openmrs.org/uploads/default/original/3X/7/c/7c6b6ffd2690267448e5ae7c5584287bdde34c23.png)

 ![image](https://talk.openmrs.org/uploads/default/original/3X/2/1/21b0761dec4d14f0654a73a825fba88b7a96f539.png)

 ![image](https://talk.openmrs.org/uploads/default/original/3X/b/d/bda262ef1005ab1bdda1469875c6bbd06d48c312.png)

#### And Carbon adds further possibility for differences…

It seems like Carbon Design’s default is the opposite of what we want - they default to MM-DD-YYYY and AM/PM time. Since our vision is for folks around the world to be building 3.x widgets with Carbon Design, this makes having a single place that sets the user’s app’s convention even _more_ important/relevant IMHO.

 ![image](https://talk.openmrs.org/uploads/default/original/3X/c/2/c21b995228796697617d71d6b147e3389145032a.png)

---

<div class="post-metadata">

**Author:** ![ibacher](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ibacher/32/19751_2.png) [@ibacher](https://talk.openmrs.org/u/ibacher)\
**Post date:** [January 26, 2022, 8:56pm UTC](https://talk.openmrs.org/t/o3-config-to-set-a-standard-date-time-convention-throughout-app/35726/3 "2022-01-26T20:56:22Z")

</div>

There’s a [related conversation from Slack](https://openmrs.slack.com/archives/CHP5QAE5R/p1639110796438300) and @bistenes has added some helpful functions to display dates in consistent formats, e.g., [formatDate](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-framework/docs/API.md#formatdate).

Rather than standardising on ISO-8601 (which we should standardise on for machine dates–it’s really a specification for machine exhange), I think the idea of adopting locale-aware date and time formatting makes sense.

---

<div class="post-metadata">

**Author:** ![burke](https://talk.openmrs.org/user_avatar/talk.openmrs.org/burke/32/17_2.png) [@burke](https://talk.openmrs.org/u/burke)\
**Post date:** [February 2, 2022, 3:47pm UTC](https://talk.openmrs.org/t/o3-config-to-set-a-standard-date-time-convention-throughout-app/35726/4 "2022-02-02T15:47:51Z")

</div>

I wouldn’t try to come up with one date display format for all implementations, since date formatting varies by locale. I think the pattern we’ve used previously was for the application to decide the type of display needed – e.g., short date (month & day) vs. full date, date & time, short time, full time – and then use utilities to generate standard, locale-specific versions.

So, for example, a table widget wants to display a short date (month & day), so it uses the utility and whether that becomes “3-Feb”, “Feb 3”, “2/3”, or “3/2” for display is decided by the utility function, which would take locale and implementation configuration preferences into consideration, to ensure dates are standardized across the app for any implementation. The locale drives whether things are “month/day” vs. “day/month” and implementer configuration could let them decide if they favor “-” or “/” delimiters, names or numbers for months, etc.

But the fundamental approach is to ensure anything display date, time, or date & time in the application uses a shared utility function and that shared utility function and ensure consistency throughout the application.
