Skip to content

Commit

Permalink
Show last month on the first of the month
Browse files Browse the repository at this point in the history
  • Loading branch information
xendk committed Oct 1, 2024
1 parent 00a2f6a commit 304a723
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Intended Effort Versioning](https://jacobtomlinson.

### Fixed
- Handle PHPs old BCrypt version.
- Show last month on the first of the month.

### Changed
- Invalid token creds results in 403 response, not an anonymous
Expand Down
10 changes: 6 additions & 4 deletions src/controllers/legacy_entity_controller.cr
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ class LegacyEntityController < ApplicationController
end
end

# Go with last month if there's not enough workdays in the current
# one.
if date_from.to_s("%Y%m") == date_today.to_s("%Y%m") &&
calc_work_days(date_from, date_today.at_beginning_of_day) < 1
# Go with last month to is less than from (happens when it's the
# current month and it's the first of the month) or if there's not
# enough workdays in the current one.
if date_from > date_to
date_from.to_s("%Y%m") == date_today.to_s("%Y%m") &&
calc_work_days(date_from, date_today.at_beginning_of_day) < 1
date_from = date_from.shift(months: -1)
date_to = date_from.at_end_of_month
end
Expand Down

0 comments on commit 304a723

Please sign in to comment.