Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ tmp/

# css is compiled from scss in /styles
public/main.css
package-lock.json
12 changes: 11 additions & 1 deletion lib/parse/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ export const parsePromise = ({
const { tini, tdue: dueDate, tfin } = promise

const text = parseText({ text: urtext })
const { eventTitle, isAllDay, startDate } = parseSherlock({ text, timezone })
let { eventTitle, isAllDay, startDate } = parseSherlock({ text, timezone })

if ( moment(startDate).isBefore(moment().subtract(1, 'years')) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, i think that this check/override should only happen when we create the the promise, so that this function still gives us what we expect

also, this will need to be a timezone aware check because we're going to change the criteria to reject any date that is in the past i.e. < now (before, at a 1 year scale, being within 24 hours wouldn't really matter)

this should happen before that closeOfBusiness check so that the default will be applied (and you can look at that function for timezone handling)

<<<<<<< HEAD
log.warn('parsePromise rejected, past due date:', startDate)
startDate = null // clear startDate if more than a year ago
=======
log.debug('Caught and fixed promise with old parsed start date of:', startDate)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 36 exceeds the maximum line length of 80.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea to log this, we should probably have it as a warn with a more succinct message like 'parsePromise rejected past due date:'

startDate = null; // clear startDate if more than a year ago

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra semicolon.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

>>>>>>> 9cc7fb723ff8ffe9392ad605ffe3ae22362c6d63
}

const tdue = dueDate || (startDate && moment(startDate)
.add(+isAllDay, 'days') // turn boolean into 1 or 0
Expand Down