Merge remote-tracking branch 'upstream/develop' into mountmaster
Conflicts: dist/habitrpg-shared.css dist/spritesmith0.css dist/spritesmith0.png dist/spritesmith1.css dist/spritesmith1.png dist/spritesmith2.css dist/spritesmith2.png dist/spritesmith3.css dist/spritesmith3.png
This commit is contained in:
+6
-8
@@ -57,7 +57,10 @@ api.startOfWeek = api.startOfWeek = (options={}) ->
|
||||
|
||||
api.startOfDay = (options={}) ->
|
||||
o = sanitizeOptions(options)
|
||||
moment(o.now).startOf('day').add({hours:o.dayStart})
|
||||
dayStart = moment(o.now).startOf('day').add({hours:o.dayStart})
|
||||
if moment(o.now).hour() < o.dayStart
|
||||
dayStart.subtract({days:1})
|
||||
dayStart
|
||||
|
||||
api.dayMapping = {0:'su',1:'m',2:'t',3:'w',4:'th',5:'f',6:'s'}
|
||||
|
||||
@@ -66,7 +69,7 @@ api.dayMapping = {0:'su',1:'m',2:'t',3:'w',4:'th',5:'f',6:'s'}
|
||||
###
|
||||
api.daysSince = (yesterday, options = {}) ->
|
||||
o = sanitizeOptions options
|
||||
Math.abs api.startOfDay(_.defaults {now:yesterday}, o).diff(o.now, 'days')
|
||||
Math.abs api.startOfDay(_.defaults {now:yesterday}, o).diff(api.startOfDay(_.defaults {now:o.now}, o), 'days')
|
||||
|
||||
###
|
||||
Should the user do this taks on this date, given the task's repeat options and user.preferences.dayStart?
|
||||
@@ -75,12 +78,7 @@ api.shouldDo = (day, repeat, options={}) ->
|
||||
return false unless repeat
|
||||
o = sanitizeOptions options
|
||||
selected = repeat[api.dayMapping[api.startOfDay(_.defaults {now:day}, o).day()]]
|
||||
return selected unless moment(day).zone(o.timezoneOffset).isSame(o.now,'d')
|
||||
if options.dayStart <= o.now.hour() # we're past the dayStart mark, is it due today?
|
||||
return selected
|
||||
else # we're not past dayStart mark, check if it was due "yesterday"
|
||||
yesterday = moment(o.now).subtract({days:1}).day() # have to wrap o.now so as not to modify original
|
||||
return repeat[api.dayMapping[yesterday]] # FIXME is this correct?? Do I need to do any timezone calcaulation here?
|
||||
return selected
|
||||
|
||||
###
|
||||
------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user