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

fix: use one-based day of week for aws cron expressions #120

Merged
merged 1 commit into from
Nov 14, 2020
Merged
Show file tree
Hide file tree
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
10 changes: 4 additions & 6 deletions src/common/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import cronstrue from 'cronstrue';
import { Admin, Protobuf } from 'flyteidl';
import * as moment from 'moment-timezone';
import {
subSecondString,
unknownValueString,
zeroSecondsString
} from './constants';
import { unknownValueString, zeroSecondsString } from './constants';
import { timezone } from './timezone';
import { durationToMilliseconds, isValidDate } from './utils';

Expand Down Expand Up @@ -202,7 +198,9 @@ export function getScheduleFrequencyString(schedule?: Admin.ISchedule) {
if (schedule.cronExpression) {
// Need to add a leading 0 to get a valid CRON expression, because
// ISchedule is using AWS-style expressions, which don't allow a `seconds` position
return cronstrue.toString(`0 ${schedule.cronExpression}`);
return cronstrue.toString(`0 ${schedule.cronExpression}`, {
dayOfWeekStartIndexZero: false
});
}
if (schedule.rate) {
return fixedRateToString(schedule.rate);
Expand Down
7 changes: 2 additions & 5 deletions src/common/test/formatters.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { millisecondsToDuration } from 'common/utils';
import { Admin } from 'flyteidl';
import * as moment from 'moment-timezone';
import {
subSecondString,
unknownValueString,
zeroSecondsString
} from '../constants';
import { unknownValueString, zeroSecondsString } from '../constants';
import {
dateDiffString,
dateFromNow,
Expand Down Expand Up @@ -199,6 +195,7 @@ describe('getScheduleFrequencyString', () => {
// input and expected result
const cases: [Admin.ISchedule, string][] = [
[{ cronExpression: '* * * * *' }, 'Every minute'],
[{ cronExpression: '0 20 ? * 3 *' }, 'At 08:00 PM, only on Tuesday'],
[
{ rate: { value: 1, unit: Admin.FixedRateUnit.MINUTE } },
'Every 1 minutes'
Expand Down