Skip to content

Commit

Permalink
feat: move days numbers to strings
Browse files Browse the repository at this point in the history
  • Loading branch information
miiila committed Jun 5, 2017
1 parent 8a88ba4 commit 98b599c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/pagerduty.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ processSchedules = (allSchedules, days = [], cb) ->
debug(myUserName)
for crossSchedule in otherSchedules
for crossCheckEntry in crossSchedule.entries
day = new Date(myStart).getUTCDay()
day = getDayAbbrev(new Date(myStart).getUTCDay())
if myStart <= crossCheckEntry.start < myEnd and
crossCheckEntry.user.id == myUserId and
(day not in days or !days.length)
Expand Down Expand Up @@ -176,6 +176,11 @@ overrideUser = (userId, scheduleId, durationInMinutes = 30, cb) ->
reponseObject = JSON.parse(body)
cb err, reponseObject.override

getDayAbbrev = (utcDay) ->
days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]

return days[utcDay]

module.exports = {
pdGet
getSchedulesIds
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/config-days.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
},
"PAGERDUTY_TOKEN" : "111111111111"
},
"EXCLUSION_DAYS": [5, 6]
"EXCLUSION_DAYS": ["Fri", "Sat"]
}]
}

0 comments on commit 98b599c

Please sign in to comment.