diff --git a/lib/__tests__/expected.yml b/lib/__tests__/expected.yml index 86aa4561..f5003f6d 100644 --- a/lib/__tests__/expected.yml +++ b/lib/__tests__/expected.yml @@ -4288,7 +4288,7 @@ Resources: Properties: Code: S3Bucket: cdk-hnb659fds-assets-712950704752-us-east-1 - S3Key: ff9251e1c9991e0788c269b3f4daac2ef4701a3e98de0bb0a1aedae2bb35a514.zip + S3Key: d81bf2d4c389ecd69472cf4b27599e1ffbe0c1543104f45d035834e863f64ca7.zip Role: Fn::GetAtt: - CodeCommitPipelineChangeControllerFunctionServiceRoleF02841DB diff --git a/lib/change-control-lambda/time-window.ts b/lib/change-control-lambda/time-window.ts index 16c7c03d..c035c133 100644 --- a/lib/change-control-lambda/time-window.ts +++ b/lib/change-control-lambda/time-window.ts @@ -39,6 +39,7 @@ type Events = { [uuid: string]: CalendarEvent }; * @returns the events that represent the blocked time, or `undefined` if `now` is not "blocked". */ export function shouldBlockPipeline(icalData: string | Buffer, now = new Date(), advanceMarginSec = 3600): CalendarEvent | undefined { + validateTz(); const events: Events = ical.parseICS(icalData.toString('utf8')); const blocks = containingEventsWithMargin(events, now, advanceMarginSec); return blocks.length > 0 ? blocks[0] : undefined; @@ -140,3 +141,9 @@ function overlaps(left: { start: Date; end: Date }, right: { start: Date; end: D function isBetween(date: Date, left: Date, right: Date): boolean { return date >= left && date <= right; } + +function validateTz() { + if (new Date().getTimezoneOffset() !== 0) { + throw new Error('Because of a bug in "node-ical", this module can only be used when the system time zone is set to UTC. Run this command again with "TZ=UTC"'); + } +}