From 5e3d69aef42d02b661a7ffe878f40de8a3881d5a Mon Sep 17 00:00:00 2001 From: Danielle Adams <6271256+danielleadams@users.noreply.github.com> Date: Thu, 9 Sep 2021 18:50:44 -0400 Subject: [PATCH] fix(amplify-category-function): specify UTC tz when selecting start time (#8053) --- .../awscloudformation/utils/cronHelper.ts | 42 +++---------------- .../src/categories/lambda-function.ts | 6 +-- 2 files changed, 9 insertions(+), 39 deletions(-) diff --git a/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/cronHelper.ts b/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/cronHelper.ts index c9c1eefb6a1..528cbad7193 100644 --- a/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/cronHelper.ts +++ b/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/cronHelper.ts @@ -43,25 +43,13 @@ export async function timeHelper(exp: CronBuilder) { const timeQuestion = { type: 'datetime', name: 'dt', - message: 'Select the start time (use arrow keys):', + message: 'Select the start time in UTC (use arrow keys):', format: ['hh', ':', 'mm', ' ', 'A'], }; const timeAnswer = await inquirer.prompt([timeQuestion]); - exp.set( - 'minute', - (timeAnswer.dt) - .getMinutes() - .toString() - .split(), - ); - exp.set( - 'hour', - (timeAnswer.dt) - .getHours() - .toString() - .split(), - ); + exp.set('minute', (timeAnswer.dt).getMinutes().toString().split()); + exp.set('hour', (timeAnswer.dt).getHours().toString().split()); return exp; } @@ -98,13 +86,7 @@ export async function monthHelper(exp, context) { const suffix = (dateAnswer.dt).getDate() === 31 ? 'st' : 'th'; context.print.warning(`Function won't be invoked on months without the ${(dateAnswer.dt).getDate()}${suffix} day`); } - exp.set( - 'dayOfTheMonth', - (dateAnswer.dt) - .getDate() - .toString() - .split(), - ); + exp.set('dayOfTheMonth', (dateAnswer.dt).getDate().toString().split()); return exp; } @@ -120,19 +102,7 @@ export async function yearHelper(exp, context) { const suffix = (dateAnswer.dt).getDate() === 31 ? 'st' : 'th'; context.print.warning(`Function won't be invoked on months without the ${(dateAnswer.dt).getDate()}${suffix} day`); } - exp.set( - 'dayOfTheMonth', - (dateAnswer.dt) - .getDate() - .toString() - .split(), - ); - exp.set( - 'month', - (dateAnswer.dt) - .getMonth() - .toString() - .split(), - ); + exp.set('dayOfTheMonth', (dateAnswer.dt).getDate().toString().split()); + exp.set('month', (dateAnswer.dt).getMonth().toString().split()); return exp; } diff --git a/packages/amplify-e2e-core/src/categories/lambda-function.ts b/packages/amplify-e2e-core/src/categories/lambda-function.ts index 51af3693069..0d398bb9135 100644 --- a/packages/amplify-e2e-core/src/categories/lambda-function.ts +++ b/packages/amplify-e2e-core/src/categories/lambda-function.ts @@ -176,7 +176,7 @@ const coreFunction = ( } } else { if (settings.layerOptions && settings.layerOptions.layerAndFunctionExist) { - chain.wait('Select which capability you want to update:').sendCarriageReturn() // lambda function + chain.wait('Select which capability you want to update:').sendCarriageReturn(); // lambda function } chain.wait('Select the Lambda function you want to update').sendCarriageReturn(); // assumes only one function configured in the project } @@ -494,7 +494,7 @@ const addWeekly = (chain: ExecutionContext) => { chain .wait('Select the day to invoke the function:') .sendCarriageReturn() - .wait('Select the start time (use arrow keys):') + .wait('Select the start time in UTC (use arrow keys):') .sendCarriageReturn(); return chain; }; @@ -520,7 +520,7 @@ const addCron = (chain: ExecutionContext, settings: any) => { addhourly(moveDown(chain, 1).sendCarriageReturn()); break; case 'Daily': - moveDown(chain, 2).sendCarriageReturn().wait('Select the start time (use arrow keys):').sendCarriageReturn(); + moveDown(chain, 2).sendCarriageReturn().wait('Select the start time in UTC (use arrow keys):').sendCarriageReturn(); break; case 'Weekly': addWeekly(moveDown(chain, 3).sendCarriageReturn());