PharmaLedger-IMI / ctr-workspace

UC8 Clinical Trials Recruitment
MIT License
2 stars 0 forks source link

ctr-backoffice-backend LFormsService DateDiff buggy #16

Closed joaoluis-pdm closed 3 years ago

joaoluis-pdm commented 3 years ago

The DateDiff tool ( introduced in commit b028e6b0a7e29614cd68bf69aff5e82988909f02 ) used to calculate the age from the difference of years from now to the birthDate is buggy. It does not take into account the number of months/days ellapsed. To fix that, we probably need moment.js diff's method - https://momentjs.com/docs/#/displaying/difference/

See also https://stackoverflow.com/questions/8152426/how-can-i-calculate-the-number-of-years-between-two-dates

Other option: After diffing the year, you may just compare MMDD >= MMDD. If false, remove 1 year from the age.

joaoluis-pdm commented 3 years ago

My turn to review

joaoluis-pdm commented 3 years ago

Seems ok now. Thanks @pccosta-pdm Closing the issue.