startOfDay: if between midnight and custom day start, jump back to previous day

This commit is contained in:
Cole Gleason
2014-01-08 22:26:43 -06:00
parent d9e8c53d9a
commit 3bd81abda3
2 changed files with 6 additions and 2 deletions
+4 -2
View File
@@ -31,7 +31,10 @@ api.startOfWeek = api.startOfWeek = (options={}) ->
api.startOfDay = (options={}) ->
o = sanitizeOptions(options)
moment(o.now).startOf('day').add('h', o.dayStart)
dayStart = moment(o.now).startOf('day').add('h', o.dayStart)
# if between midnight and Custom Day Start, jump back to previous day
dayStart.subtract('day', 1) if moment(o.now).isBefore(dayStart)
return dayStart
dayMapping = {0:'su',1:'m',2:'t',3:'w',4:'th',5:'f',6:'s'}
@@ -1239,4 +1242,3 @@ api.wrap = (user, main=true) ->
get: ->
tasks = user.habits.concat(user.dailys).concat(user.todos).concat(user.rewards)
_.object(_.pluck(tasks, "id"), tasks)