Skip to content

Commit

Permalink
tasks: extract variable
Browse files Browse the repository at this point in the history
  • Loading branch information
facuspagnuolo committed Oct 19, 2023
1 parent 7493676 commit 0afb342
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/tasks/contracts/base/TimeLockedTask.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ abstract contract TimeLockedTask is ITimeLockedTask, Authorized {
}
} else {
if (block.timestamp >= allowedAt && block.timestamp <= allowedAt + window) {
// Check the current timestamp has not passed the allowed at set
// Check the current timestamp has not passed the allowed date set
_nextAllowedAt = _getNextAllowedDate(allowedAt, frequency);
} else {
// Check the current timestamp is not before the current allowed date
Expand Down Expand Up @@ -223,8 +223,9 @@ abstract contract TimeLockedTask is ITimeLockedTask, Authorized {
*/
function _getNextAllowedDate(uint256 allowedAt, uint256 monthsToIncrease) private view returns (uint256) {
(uint256 year, uint256 month, uint256 day) = allowedAt.timestampToDate();
uint256 nextMonth = (month + monthsToIncrease) % 12;
uint256 nextYear = year + ((month + monthsToIncrease) / 12);
uint256 increasedMonth = month + monthsToIncrease;
uint256 nextMonth = increasedMonth % 12;
uint256 nextYear = year + (increasedMonth / 12);
uint256 nextDay = _mode == Mode.OnLastMonthDay ? DateTime._getDaysInMonth(nextYear, nextMonth) : day;
return _getAllowedDateFor(allowedAt, nextYear, nextMonth, nextDay);
}
Expand Down

0 comments on commit 0afb342

Please sign in to comment.