diff --git a/absences.go b/absences.go index 0e6f61b..0b9aa43 100644 --- a/absences.go +++ b/absences.go @@ -22,10 +22,10 @@ func (s *Store) AddAbsence(ctx context.Context, session time.Time, userId string )) defer span.End() - if session.Weekday() != time.Monday { - log.Debug().Ctx(ctx).Msg(fmt.Sprintf("%s is not a monday", session)) - span.RecordError(fmt.Errorf("%s is not a monday", session)) - return fmt.Errorf("not a monday") + if session.Weekday() != time.Wednesday { + log.Debug().Ctx(ctx).Msg(fmt.Sprintf("%s is not a wednesday", session)) + span.RecordError(fmt.Errorf("%s is not a wednesday", session)) + return fmt.Errorf("not a wednesday") } defer s.Audit(ctx, &AuditableEvent{ diff --git a/cmd/themis-server/main.go b/cmd/themis-server/main.go index 1175bc3..ecd28dc 100644 --- a/cmd/themis-server/main.go +++ b/cmd/themis-server/main.go @@ -580,7 +580,7 @@ func main() { return nil }, "schedule": func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error { - // get schedule from now to 4 mondays into the future + // get schedule from now to 4 wednesdays into the future sched, err := store.GetSchedule(ctx, themis.NextWednesday(), themis.NextWednesday().Add(4*7*24*time.Hour)) if err != nil { if err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ @@ -675,17 +675,17 @@ func main() { return nil } - if date.Weekday() != time.Monday { + if date.Weekday() != time.Wednesday { if err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ Flags: discordgo.MessageFlagsEphemeral, - Content: "The date you provided is not a Monday.", + Content: "The date you provided is not a Wednesday.", }, }); err != nil { return fmt.Errorf("failed to respond to interaction: %w", err) } - // TODO(wperron) suggest Mondays before and after? + // TODO(wperron) suggest Wednesdays before and after? return nil } @@ -753,7 +753,7 @@ func main() { var msg string var components []discordgo.MessageComponent if len(absentees) == 0 { - msg = "Everybody can make it next Monday, see you then! 🎉" + msg = "Everybody can make it next Wednesday, see you then! 🎉" components = []discordgo.MessageComponent{ discordgo.ActionsRow{ Components: []discordgo.MessageComponent{ @@ -770,7 +770,7 @@ func main() { }, } } else { - msg = fmt.Sprintf("%s can't make it next Monday. 🙁", themis.FormatStringSlice(absentees)) + msg = fmt.Sprintf("%s can't make it next Wednesday. 🙁", themis.FormatStringSlice(absentees)) } _, err = discord.ChannelMessageSendComplex(channelId, &discordgo.MessageSend{ diff --git a/notify.go b/notify.go index 791ed9d..5fe3e4e 100644 --- a/notify.go +++ b/notify.go @@ -34,7 +34,7 @@ func (n *Notifier) Start(ctx context.Context) { t, err := time.ParseInLocation(time.DateTime, fmt.Sprintf("%s 17:00:00", sat.Format(time.DateOnly)), loc) if err != nil { - panic("failed to parse next monday notif time. this is likely a bug.") + panic("failed to parse next wednesday notif time. this is likely a bug.") } log.Debug().Time("next", t).Msg("starting notifier instance") diff --git a/time.go b/time.go index dd60a99..5aa5a27 100644 --- a/time.go +++ b/time.go @@ -8,10 +8,6 @@ func init() { now = time.Now } -func NextMonday() time.Time { - return now().AddDate(0, 0, int((8-now().Weekday())%7)) -} - func NextWednesday() time.Time { return now().AddDate(0, 0, int((10-now().Weekday())%7)) } diff --git a/time_test.go b/time_test.go index f2d71a7..6a16926 100644 --- a/time_test.go +++ b/time_test.go @@ -6,14 +6,14 @@ import ( "time" ) -func TestNextMonday(t *testing.T) { +func TestNextWednesday(t *testing.T) { tests := []struct { name string seed string want string }{ { - name: "on monday", + name: "on wednesday", seed: "2023-11-13T15:04:05Z07:00", want: "2023-11-13T15:04:05Z07:00", }, @@ -38,8 +38,8 @@ func TestNextMonday(t *testing.T) { seedt, _ := time.Parse(time.RFC3339, tt.seed) now = func() time.Time { return seedt } wantt, _ := time.Parse(time.RFC3339, tt.want) - if got := NextMonday(); !reflect.DeepEqual(got, wantt) { - t.Errorf("NextMonday() = %v, want %v", got, wantt) + if got := NextWednesday(); !reflect.DeepEqual(got, wantt) { + t.Errorf("NextWednesday() = %v, want %v", got, wantt) } }) }