@openmrs/esm-utils 6.2.1-pre.2854 → 6.2.1-pre.2860

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-utils",
3
- "version": "6.2.1-pre.2854",
3
+ "version": "6.2.1-pre.2860",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Helper utilities for OpenMRS",
6
6
  "browser": "dist/openmrs-esm-utils.js",
@@ -39,7 +39,7 @@
39
39
  "access": "public"
40
40
  },
41
41
  "devDependencies": {
42
- "@openmrs/esm-globals": "6.2.1-pre.2854",
42
+ "@openmrs/esm-globals": "6.2.1-pre.2860",
43
43
  "@types/lodash-es": "^4.17.12",
44
44
  "@types/semver": "^7.3.4",
45
45
  "dayjs": "^1.10.4",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@formatjs/intl-durationformat": "^0.7.3",
57
- "@internationalized/date": "^3.5.5",
57
+ "@internationalized/date": "^3.8.0",
58
58
  "any-date-parser": "^2.0.3",
59
59
  "lodash-es": "^4.17.21",
60
60
  "semver": "7.3.2"
@@ -3,11 +3,12 @@
3
3
  * @category Date and Time
4
4
  */
5
5
  import {
6
+ type CalendarDate,
6
7
  type CalendarDateTime,
8
+ type CalendarIdentifier,
7
9
  type ZonedDateTime,
8
10
  createCalendar,
9
11
  toCalendar,
10
- type CalendarDate,
11
12
  } from '@internationalized/date';
12
13
  import { getLocale } from '@openmrs/esm-utils';
13
14
  import { attempt } from 'any-date-parser';
@@ -99,21 +100,21 @@ export function parseDate(dateString: string) {
99
100
  * Internal cache for per-locale calendars
100
101
  */
101
102
  class LocaleCalendars {
102
- #registry = new Map<string, string>();
103
+ #registry = new Map<string, CalendarIdentifier>();
103
104
 
104
105
  constructor() {}
105
106
 
106
- register(locale: string, calendar: string) {
107
+ register(locale: string, calendar: CalendarIdentifier) {
107
108
  this.#registry.set(locale, calendar);
108
109
  }
109
110
 
110
- getCalendar(locale: Intl.Locale) {
111
+ getCalendar(locale: Intl.Locale): CalendarIdentifier | undefined {
111
112
  if (!Boolean(locale)) {
112
113
  return undefined;
113
114
  }
114
115
 
115
116
  if (locale.calendar) {
116
- return locale.calendar;
117
+ return locale.calendar as CalendarIdentifier;
117
118
  }
118
119
 
119
120
  if (locale.region) {
@@ -127,7 +128,7 @@ class LocaleCalendars {
127
128
  return this.#registry.get(locale.language);
128
129
  }
129
130
 
130
- const defaultCalendar = new Intl.DateTimeFormat(locale.toString()).resolvedOptions().calendar;
131
+ const defaultCalendar = new Intl.DateTimeFormat(locale.toString()).resolvedOptions().calendar as CalendarIdentifier;
131
132
 
132
133
  // cache this result
133
134
  this.#registry.set(`${locale.language}${locale.region ? `-${locale.region}` : ''}`, defaultCalendar);
@@ -149,7 +150,7 @@ const registeredLocaleCalendars = new LocaleCalendars();
149
150
  * @param locale the locale to register this calendar for
150
151
  * @param calendar the calendar to use for this registration
151
152
  */
152
- export function registerDefaultCalendar(locale: string, calendar: string) {
153
+ export function registerDefaultCalendar(locale: string, calendar: CalendarIdentifier) {
153
154
  registeredLocaleCalendars.register(locale, calendar);
154
155
  }
155
156