-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: check first week of next year, get period by date [LIBS-688] #74
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #74 +/- ##
==========================================
+ Coverage 91.25% 91.27% +0.01%
==========================================
Files 56 56
Lines 1201 1203 +2
Branches 326 329 +3
==========================================
+ Hits 1096 1098 +2
Misses 103 103
Partials 2 2 ☔ View full report in Codecov by Sentry. |
@@ -102,13 +118,21 @@ describe('Gregorian Calendar period by date calculation', () => { | |||
expect(actual?.id).toBe('2020BiW26') | |||
}) | |||
|
|||
it('should return "2020SunW1" for period type "BIWEEKLY" on "2020-01-01"', () => { | |||
it('should return "2020BiW1" for period type "BIWEEKLY" on "2020-01-01"', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just fixing typo in test description
@@ -136,7 +147,7 @@ describe('Ethiopic Calendar period by date calculation', () => { | |||
expect(actual?.id).toBe('2014BiW26') | |||
}) | |||
|
|||
it('should return "2012SunW1" for period type "BIWEEKLY" on "2012-01-01"', () => { | |||
it('should return "2012BiW1" for period type "BIWEEKLY" on "2012-01-01"', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just fixing typo in test description
@@ -21,8 +21,8 @@ const getWeeklyFixedPeriodByDate: GetWeeklyFixedPeriodByDate = ({ | |||
startingDay: 1, | |||
}) | |||
|
|||
// if start date of first period of year is after current date get last | |||
// period of last year | |||
// if current date is before start date of first period of year |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just modified the language of the comment here, so that it more closely matched the actual logical operation performed below
## [1.3.2](v1.3.1...v1.3.2) (2024-10-09) ### Bug Fixes * check first week of subsequent year when geting period by date [LIBS-688] ([#74](#74)) ([8662fe0](8662fe0))
🎉 This PR is included in version 1.3.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [2.0.0-alpha.6](v2.0.0-alpha.5...v2.0.0-alpha.6) (2024-11-21) ### Bug Fixes * check first week of subsequent year when geting period by date [LIBS-688] ([#74](#74)) ([8662fe0](8662fe0))
🎉 This PR is included in version 2.0.0-alpha.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
See: https://dhis2.atlassian.net/jira/software/c/projects/LIBS/issues/LIBS-688
I've amended the logic of GetWeeklyFixedPeriodByDate to return the first period of the subsequent year if the requested date is after the end date of the the periods for the year. This logic mirrors the existing logic for returning the previous year's last week if requested date is before the start date of the first period of the year.
I guess a slightly safer implementation would also perform the check on the previous year/subsequent year's period to make sure the requested date is in range, but I assume it should not be necessary.