Skip to content

Commit 8e30f4e

Browse files
Added updated Age calculation for IPD CareView (#256)
* Added updated Age calulation * Formated changes reverted
1 parent 875a729 commit 8e30f4e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/utils/DateTimeUtils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export const getAgeInYearsMonthsDays = (
165165
return "";
166166
}
167167
const birth = moment.utc(birthDate);
168-
const now = moment.utc(currentDate).startOf('day');
168+
const now = moment.utc(currentDate);
169169

170170
if (!birth.isValid() || !now.isValid() || birth.isAfter(now)) {
171171
console.warn(
@@ -188,18 +188,18 @@ export const getAgeInYearsMonthsDays = (
188188
const formattedYear = intl.formatMessage({ id: yearId, defaultMessage: yearDefault });
189189
parts.push(`${years} ${formattedYear}`);
190190
}
191-
if (months > 0) {
191+
if (years > 0 || months > 0) {
192192
const monthId = "CLINICAL_MONTHS_TRANSLATION_KEY";
193193
const monthDefault = "Months";
194194
const formattedMonth = intl.formatMessage({ id: monthId, defaultMessage: monthDefault });
195195
parts.push(`${months} ${formattedMonth}`);
196196
}
197-
if (days > 0 || (years === 0 && months === 0)) {
197+
if ( years > 0 || months > 0 || days > 0 || (years === 0 && months === 0 && days === 0)) {
198198
const dayId = "CLINICAL_DAYS_TRANSLATION_KEY";
199199
const dayDefault = "Days";
200200
const formattedDay = intl.formatMessage({ id: dayId, defaultMessage: dayDefault });
201201
parts.push(`${days} ${formattedDay}`);
202202
}
203203

204204
return parts.join(", ");
205-
};
205+
};

0 commit comments

Comments
 (0)