diff --git a/coderd/autobuild/schedule/schedule.go b/coderd/autobuild/schedule/schedule.go index 076c96f062cba..43afcf2223a28 100644 --- a/coderd/autobuild/schedule/schedule.go +++ b/coderd/autobuild/schedule/schedule.go @@ -144,7 +144,7 @@ func (s Schedule) Time() string { minute := strings.Fields(s.cronStr)[0] hour := strings.Fields(s.cronStr)[1] maybeTime := fmt.Sprintf("%s:%s", hour, minute) - t, err := time.ParseInLocation("3:4", maybeTime, s.sched.Location) + t, err := time.ParseInLocation("15:4", maybeTime, s.sched.Location) if err != nil { // return the original cronspec for minute and hour, who knows what's in there! return fmt.Sprintf("cron(%s %s)", minute, hour) diff --git a/coderd/autobuild/schedule/schedule_test.go b/coderd/autobuild/schedule/schedule_test.go index be30d19972bb9..ccba3e4f37773 100644 --- a/coderd/autobuild/schedule/schedule_test.go +++ b/coderd/autobuild/schedule/schedule_test.go @@ -50,6 +50,19 @@ func Test_Weekly(t *testing.T) { expectedString: "CRON_TZ=UTC 30 9 * * 1-5", expectedTime: "9:30AM", }, + { + name: "24h format", + spec: "30 13 * * 1-5", + at: time.Date(2022, 4, 1, 13, 29, 0, 0, time.UTC), + expectedNext: time.Date(2022, 4, 1, 13, 30, 0, 0, time.UTC), + expectedMin: 24 * time.Hour, + expectedDaysOfWeek: "Mon-Fri", + expectedError: "", + expectedCron: "30 13 * * 1-5", + expectedLocation: time.UTC, + expectedString: "CRON_TZ=UTC 30 13 * * 1-5", + expectedTime: "1:30PM", + }, { name: "convoluted with timezone", spec: "CRON_TZ=US/Central */5 12-18 * * 1,3,6", @@ -141,6 +154,7 @@ func Test_Weekly(t *testing.T) { require.Equal(t, testCase.expectedString, actual.String()) require.Equal(t, testCase.expectedMin, actual.Min()) require.Equal(t, testCase.expectedDaysOfWeek, actual.DaysOfWeek()) + require.Equal(t, testCase.expectedTime, actual.Time()) } else { require.EqualError(t, err, testCase.expectedError) require.Nil(t, actual) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy