Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: FacilitateIncidentReview date helper #303

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/commands/scheduled/facilitate-incident-review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class FacilitateIncidentReview extends Command {
...Command.flags,
date: flags.string({
description: "target date in ISO format",
default: wednesday11AM(),
default: wednesdayShift(),
}),
schedule: flags.string({
description: "schedule name",
Expand Down Expand Up @@ -78,10 +78,12 @@ async function onCallParticipantEmails(
)
}

// By default we want to select on-call participants starting Wednesday at 11AM ET
function wednesday11AM() {
const wednesday = new Date()
wednesday.setDate(wednesday.getDate() - wednesday.getDay() + 3)
wednesday.setHours(11, 0, 0, 0)
// By default we want to select on-call participants after Wednesday at 11AM ET
// because that is when the on-call schedule is updated.
// Setting the default to Wednesday at 2PM ET to avoid issues when daylight savings time shifts.
function wednesdayShift() {
const wednesday = new Date() // this returns the current date and time in UTC
wednesday.setDate(wednesday.getDate() - wednesday.getDay() + 3) // 3 = Wednesday
wednesday.setHours(18, 0, 0, 0) // 18 in UTC = 2PM ET (when daylight savings time is in effect)
return wednesday.toISOString()
}