From fedeabc693a7450e24ed202e2e57388439d5d05a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 5 Apr 2019 19:35:15 +0100 Subject: Fix timezone offset bug with scheduling events --- scripts/toy.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/toy.groovy b/scripts/toy.groovy index b0155e7..a769153 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -1502,7 +1502,7 @@ def playEvent = { rt = true, first = true -> showLounge(); } def sleepSchedule = { - def t = (int)(getDay() + localTimeOffset() + (25.1 * HOUR) + getRandom((int)HOUR)); + def t = (int)(getDay() - localTimeOffset() + (25.1 * HOUR) + getRandom((int)HOUR)); addEventIfMissing(SLEEPING, t, BEDTIME); }; def bedtime = { rt, schedTime -> @@ -1711,7 +1711,7 @@ def confess = { // Setup // Plans - cannot overlap def setupPlan = { plan, float startmin, float startmax, float endmin, float endmax -> - def timeWindow = { float min, float max -> (int)((min * HOUR) + localTimeOffset() + getRandom((int)((max - min) * HOUR))) }; + def timeWindow = { float min, float max -> (int)((min * HOUR) - localTimeOffset() + getRandom((int)((max - min) * HOUR))) }; final friendName = FRIENDS[getRandom(FRIENDS.size())]; def day = getDay() + ((getRandom(3) + 1) * DAY); addEventIfMissing(plan, day + timeWindow(startmin, startmax), BEGINPLAN, @@ -1885,7 +1885,7 @@ def setupShowCalendar = { setDefault("toy.owner", "ancilla"); OWNER = loadString("toy.owner"); DOMME = loadDomme(OWNER); -def getDayNum = { Math.floorDiv(getTime() + localTimeOffset() - 14400, 86400) }; +def getDayNum = { Math.floorDiv(getTime() - localTimeOffset() - 14400, 86400) }; def getAvail = { dayNum -> loadInteger("toy.availability.$dayNum") ?: 0 }; def addAvail = { amount -> def dayNum = getDayNum(); -- cgit v1.2.3