Skip to content

Commit

Permalink
fix: use one-based day of week for aws cron expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
schottra committed Nov 13, 2020
1 parent f0ba33e commit f2d19f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
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

0 comments on commit f2d19f9

Please sign in to comment.