Skip to content

Commit

Permalink
fix: weekday math
Browse files Browse the repository at this point in the history
  • Loading branch information
gzeoneth committed Aug 29, 2024
1 parent fd2a46d commit e3582d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gov-action-contracts/util/OfficeHoursAction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ contract OfficeHoursAction {
if (block.timestamp < minimumTimestamp) revert MinimumTimestampNotMet();

// Convert timestamp to weekday (1 = Monday, 7 = Sunday)
// Addiding 4 because Unix epoch (January 1, 1970) was a Thursday
uint256 weekday = ((block.timestamp / 86_400 + 4) % 7);
// Addiding 3 because Unix epoch (January 1, 1970) was a Thursday
uint256 weekday = ((block.timestamp / 86_400 + 3) % 7 + 1);
if (weekday < minDayOfWeek || weekday > maxDayOfWeek) revert OutsideOfficeDays();

// This is UTC time, leap seconds are not accounted for
Expand Down

0 comments on commit e3582d8

Please sign in to comment.