This PR updates the CalculateAge logic to perform calculations using Date-based birthday and Today() when the precision is years or months. This is based on the following language in the spec:
Note that for AgeInYears and AgeInMonths, the birthDate is specified as a Date and Today() is used to obtain the current date; whereas with the other precisions, birthDate is specified as a DateTime, and Now() is used to obtain the current DateTime.
Prior to this change, results for AgeInYears and AgeInMonths could be uncertainties when the birthday is today (since it was considering time components in the calculation).
As part of this change, I've updated some of the existing tests to use a fixed execution datetime, as that makes the tests more reliable (and insusceptible to DST issues). This allowed me to also unskip some previously skipped tests. I've also introduced new tests to ensure the behavior is as expected when using year and month precision.
Fixes #273
Submitter:
[x] This pull request describes why these changes were made
[x] Code diff has been done and been reviewed (it does not contain: additional white space, not applicable code changes, debug statements, etc.)
[x] Tests are included and test edge cases
[x] Tests have been run locally and pass
[x] Code coverage has not gone down and all code touched or added is covered.
[x] Code passes lint and prettier (hint: use npm run test:plus to run tests, lint, and prettier)
[x] All dependent libraries are appropriately updated or have a corresponding PR related to this change
[x] cql4browsers.js built with npm run build:browserify if source changed.
Reviewer:
Name:
[x] Code is maintainable and reusable, reuses existing code and infrastructure where appropriate, and accomplishes the task’s purpose
[x] The tests appropriately test the new code, including edge cases
This PR updates the
CalculateAge
logic to perform calculations usingDate
-based birthday andToday()
when the precision is years or months. This is based on the following language in the spec:Prior to this change, results for
AgeInYears
andAgeInMonths
could be uncertainties when the birthday is today (since it was considering time components in the calculation).As part of this change, I've updated some of the existing tests to use a fixed execution datetime, as that makes the tests more reliable (and insusceptible to DST issues). This allowed me to also unskip some previously skipped tests. I've also introduced new tests to ensure the behavior is as expected when using year and month precision.
Fixes #273
Submitter:
npm run test:plus
to run tests, lint, and prettier)cql4browsers.js
built withnpm run build:browserify
if source changed.Reviewer:
Name: