@openmrs/esm-utils 5.8.1-pre.2242 → 5.8.1-pre.2248
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": "5.8.1-pre.
|
|
3
|
+
"version": "5.8.1-pre.2248",
|
|
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": "5.8.1-pre.
|
|
42
|
+
"@openmrs/esm-globals": "5.8.1-pre.2248",
|
|
43
43
|
"@types/semver": "^7.3.4",
|
|
44
44
|
"dayjs": "^1.10.4",
|
|
45
45
|
"rxjs": "^6.5.3"
|
package/src/age-helpers.ts
CHANGED
|
@@ -10,11 +10,15 @@ import { type DurationInput } from '@formatjs/intl-durationformat/src/types';
|
|
|
10
10
|
* https://webarchive.nationalarchives.gov.uk/ukgwa/20160921162509mp_/http://systems.digital.nhs.uk/data/cui/uig/patben.pdf
|
|
11
11
|
* (See Tables 7 and 8)
|
|
12
12
|
*
|
|
13
|
-
* @param birthDate The birthDate.
|
|
13
|
+
* @param birthDate The birthDate. If birthDate is null, returns null.
|
|
14
14
|
* @param currentDate Optional. If provided, calculates the age of the person at the provided currentDate (instead of now).
|
|
15
15
|
* @returns A human-readable string version of the age.
|
|
16
16
|
*/
|
|
17
|
-
export function age(birthDate: dayjs.ConfigType, currentDate: dayjs.ConfigType = dayjs()): string {
|
|
17
|
+
export function age(birthDate: dayjs.ConfigType, currentDate: dayjs.ConfigType = dayjs()): string | null {
|
|
18
|
+
if (birthDate == null) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
const to = dayjs(currentDate);
|
|
19
23
|
const from = dayjs(birthDate);
|
|
20
24
|
|