Skip to content

Commit

Permalink
fix middle of end of logic
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Mar 11, 2021
1 parent 7a3e4d9 commit 71b3776
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion plugins/dates/scratch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const context = {
}

// let doc = nlp('end of april')
let doc = nlp('middle of tuesday') //.debug()
let doc = nlp('middle of next quarter') //.debug()

let dates = doc.dates(context)
dates = dates.get()
Expand Down
17 changes: 9 additions & 8 deletions plugins/dates/src/parseDate/units/_day.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ class Day extends Unit {
this.d = this.d.startOf('day')
}
}
middle() {
this.d = this.d.time('10am')
return this
}
beforeEnd() {
this.d = this.d.time('2pm')
return this
}
}

// like 'feb 2'
Expand All @@ -33,7 +41,7 @@ class CalendarDate extends Day {
class WeekDay extends Day {
constructor(input, unit, context) {
super(input, unit, context)
this.unit = 'week'
this.unit = 'day'
// is the input just a weekday?
if (typeof input === 'string') {
this.d = spacetime(context.today, context.timezone)
Expand All @@ -53,13 +61,6 @@ class WeekDay extends Day {
clone() {
return new WeekDay(this.d, this.unit, this.context)
}
end() {
this.d = this.d.endOf('day')
if (this.context.dayEnd) {
this.d = this.d.time(this.context.dayEnd)
}
return this
}
next() {
this.d = this.d.add(7, 'days')
this.d = this.d.day(this.weekDay)
Expand Down

0 comments on commit 71b3776

Please sign in to comment.