Skip to content

Add additional test cases for a leap year

What does this MR do and why?

Adds additional test cases to the nYearsBefore and nYearsAfter test suite, testing for the date calculation when leap day occurs.

Follow up to this discussion: !138003 (comment 1678992713)

Note

When the date in question is Feb 29, the default JS function returns March 01, unfortunately the equivalent calculation in Rails, returns Feb 28. To align the JS date calculation with the rails backend, we manually check for Feb 29 and will return the Feb 28 date for the relevant year, this appears to be the same behaviour in the momentjs and datefns JS libraries.

JS Rails
Screenshot_2023-12-08_at_9.33.47_am__1_ Screenshot_2023-12-08_at_8.44.25_am__1_

Screenshots or screen recordings

No visual changes

How to set up and validate locally

yarn jest spec/frontend/lib/utils/datetime_utility_spec.js

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Ezekiel Kigbo

Merge request reports