From ce56c4fd536039f147e58d10a821c0c2802b63d9 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 31 Mar 2021 04:29:39 +0100 Subject: [PATCH] tracker: assign midnight with only one Date object Avoid an extra Date object, and make the code slightly smaller. --- assets/src/js/tracker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/src/js/tracker.js b/assets/src/js/tracker.js index 80605df1..51d1989b 100644 --- a/assets/src/js/tracker.js +++ b/assets/src/js/tracker.js @@ -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 ) {