Skip to content

Commit

Permalink
tracker: assign midnight with only one Date object
Browse files Browse the repository at this point in the history
Avoid an extra Date object, and make the code slightly smaller.
  • Loading branch information
Krinkle committed Mar 31, 2021
1 parent 69baac5 commit ce56c4f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assets/src/js/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@
img.setAttribute('aria-hidden', 'true');
img.src = url + stringifyObject(d);
img.addEventListener('load', function() {
let now = new Date();
let midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 24, 0, 0);
let midnight = new Date();
midnight.setHours(24); midnight.setMinutes(0); midnight.setSeconds(0);

// update data in cookie
if( data.pagesViewed.indexOf(path) == -1 ) {
Expand Down

0 comments on commit ce56c4f

Please sign in to comment.