Skip to content

Commit

Permalink
ok actually maybe finally fixed daily early rollover bug
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchadwick committed Nov 12, 2024
1 parent 2080aea commit 49f6c1c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions assets/php/daily.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
$epochDateTime = new DateTime('2024-08-26', $tz);
$serverDateTime = new DateTime('now', $tz);

// daily puzzle index is equal to number of days since epoch
$index = $epochDateTime->diff($serverDateTime)->format('%a');
// daily puzzle index == days since epoch (int)
$index = intval($epochDateTime->diff($serverDateTime)->format('%a'));

// get unique date string for today
$today = date($DATE_FORMAT, $serverDateTime->getTimestamp());
// get unique date string for today (int-> string)
$today = $serverDateTime->format($DATE_FORMAT);

// get integer hash for today
// get integer hash for today (hex)
$hashHex = hash($HASH_ALGO, strval($today));

// get today's setupId (hex -> int)
$setupId = base_convert($hashHex, 16, 10);
$setupId = intval(base_convert($hashHex, 16, 10));

echo json_encode(array(
'index' => $index,
'message' => 'Got daily setupId and index',
'setupId' => $setupId,
'status' => 'ok'
'status' => 'ok',
));
?>

0 comments on commit 49f6c1c

Please sign in to comment.