From 03906f82bad01da4493309d838bb8684fbf61e35 Mon Sep 17 00:00:00 2001 From: Kyle Seifert Date: Fri, 16 Apr 2021 15:45:39 -0600 Subject: [PATCH] conform date context to standard --- src/flow-spec/IBlock.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/flow-spec/IBlock.ts b/src/flow-spec/IBlock.ts index d3702913..a28b3c43 100644 --- a/src/flow-spec/IBlock.ts +++ b/src/flow-spec/IBlock.ts @@ -144,14 +144,22 @@ export function createEvalContextFrom(context: IContext): object { prompt = cursor.promptConfig } - const today = new Date() - const tomorrow = new Date() - const yesterday = new Date() - - tomorrow.setDate(today.getDate() + 1) - tomorrow.setHours(0, 0, 0, 0) - yesterday.setDate(today.getDate() - 1) - yesterday.setHours(0, 0, 0, 0) + // now is todays full date + time + const now = new Date() + + // today is just today's day, at midnight + const today = new Date(now) + today.setHours(0, 0, 0, 0); + + // tomorrow and yesterday also midnight + const tomorrow = new Date(now) + const yesterday = new Date(now) + + tomorrow.setDate(now.getDate() + 1) + tomorrow.setHours(0, 0, 0, 0); + + yesterday.setDate(now.getDate() - 1) + yesterday.setHours(0, 0, 0, 0); return { contact: createEvalContactFrom(contact),