From 421b243fb88673709386661f6fb053ecef9e56e2 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 22 Apr 2018 21:18:46 +1000 Subject: src/loslib.js: Calculate yday of passed in Date, not the current date --- src/loslib.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/loslib.js b/src/loslib.js index b58b368..89b5399 100644 --- a/src/loslib.js +++ b/src/loslib.js @@ -76,8 +76,7 @@ const setallfields = function(L, time, utc) { setfield(L, "month", (utc ? time.getUTCMonth() : time.getMonth()) + 1); setfield(L, "year", utc ? time.getUTCFullYear() : time.getFullYear()); setfield(L, "wday", (utc ? time.getUTCDay() : time.getDay()) + 1); - let now = new Date(); - setfield(L, "yday", Math.floor((now - (new Date(now.getFullYear(), 0, 0))) / (1000 * 60 * 60 * 24))); + setfield(L, "yday", Math.floor((time - (new Date(time.getFullYear(), 0, 0 /* shortcut to correct day by one */))) / 86400000)); // setboolfield(L, "isdst", time.get); }; -- cgit v1.2.3-70-g09d2