From d1805f91814f1bb114face7de547645190dddb7d Mon Sep 17 00:00:00 2001 From: Allen Pan Date: Fri, 15 May 2015 20:21:43 -0700 Subject: [PATCH] =?UTF-8?q?Fixed=20issue=20where=20incorrect=20time=20type?= =?UTF-8?q?=20passed=20in=20for=20shouldDo=E2=80=99s=20=E2=80=98day?= =?UTF-8?q?=E2=80=99=20argument=20(should=20be=20a=20Date,=20sometimes=20M?= =?UTF-8?q?oment=20is=20passed=20in).=20Fixed=20incorrect=20comparison=20b?= =?UTF-8?q?etween=20Moment=20and=20Date.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/script/index.coffee | 6 +++--- test/common/algos.mocha.coffee | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/script/index.coffee b/common/script/index.coffee index 0ea1af6e9e..5cd774f15c 100644 --- a/common/script/index.coffee +++ b/common/script/index.coffee @@ -86,7 +86,7 @@ api.shouldDo = (day, dailyTask, options = {}) -> dayOfWeek = api.startOfDay(_.defaults {now:day}, o).day() # check if event is in the future - hasStartedCheck = moment(day).isAfter(dailyTask.startDate) || moment(day).isSame(dailyTask.startDate) + hasStartedCheck = day >= dailyTask.startDate if dailyTask.frequency == 'daily' daysSinceTaskStart = api.numDaysApart(day, dailyTask.startDate, o) @@ -1547,7 +1547,7 @@ api.wrap = (user, main=true) -> {completed, repeat} = daily thatDay = moment(now).subtract({days: 1}) - if api.shouldDo(thatDay, repeat, user.preferences) || completed + if api.shouldDo(thatDay.toDate(), daily, user.preferences) || completed _.each daily.checklist, ((box)->box.completed=false;true) daily.completed = false return @@ -1574,7 +1574,7 @@ api.wrap = (user, main=true) -> scheduleMisses = 0 _.times daysMissed, (n) -> thatDay = moment(now).subtract({days: n + 1}) - if api.shouldDo(thatDay, task, user.preferences) + if api.shouldDo(thatDay.toDate(), task, user.preferences) scheduleMisses++ if user.stats.buffs.stealth user.stats.buffs.stealth-- diff --git a/test/common/algos.mocha.coffee b/test/common/algos.mocha.coffee index e6a709edf4..4fc9431d86 100644 --- a/test/common/algos.mocha.coffee +++ b/test/common/algos.mocha.coffee @@ -793,7 +793,7 @@ describe 'Cron', -> before.dailys[0].streak = after.dailys[0].streak = 10 before.dailys[0].completed = after.dailys[0].completed = true if options.checked if options.shouldDo - expect(shared.shouldDo(now, options.repeat, {timezoneOffset, dayStart:options.dayStart, now})).to.be.ok() + expect(shared.shouldDo(now.toDate(), options.repeat, {timezoneOffset, dayStart:options.dayStart, now})).to.be.ok() after.fns.cron {now} before.stats.mp=after.stats.mp #FIXME switch options.expect