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

Fixes off-by-one error with months in Trigger #66

Merged
merged 1 commit into from
Nov 6, 2018
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
5 changes: 3 additions & 2 deletions frontend/src/lib/TriggerUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ describe('TriggerUtils', () => {
expect(pickersToDate(false, 'some string', 'some string')).toBeUndefined();
});

const date = new Date(2018, 8, 13, 17, 33);
// JS dates are 0-indexed, so 0 here is actually January.
const date = new Date(2018, 0, 13, 17, 33);
it('converts picker format to date if hasDate is true', () => {
expect(pickersToDate(true, '2018-8-13', '17:33')!.toISOString()).toBe(date.toISOString());
expect(pickersToDate(true, '2018-1-13', '17:33')!.toISOString()).toBe(date.toISOString());
});

it('throws on bad format', () => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/TriggerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function pickersToDate(hasDate: boolean, dateStr: string, timeStr: string
const [year, month, date] = dateStr.split('-');
const [hour, minute] = timeStr.split(':');

const d = new Date(+year, +month, +date, +hour, +minute);
const d = new Date(+year, (+month - 1), +date, +hour, +minute);
if (isNaN(d as any)) {
throw new Error('Invalid picker format');
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/NewRun.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class NewRun extends Page<{}, NewRunState> {
<div className={commonCss.header}>Run parameters</div>
<div>{this._runParametersMessage(pipeline)}</div>

{pipeline && pipeline.parameters && pipeline.parameters.length && (
{pipeline && pipeline.parameters && !!pipeline.parameters.length && (
<div>
{pipeline && (pipeline.parameters || []).map((param, i) =>
<TextField key={i} variant='outlined' label={param.name} value={param.value || ''}
Expand Down