Skip to content

Commit

Permalink
fix: 最近,根据timeoption自定义是未来时间还是过去时间
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangsonglei committed Feb 1, 2024
1 parent e358bbe commit d413f70
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,13 @@ trait Rules extends DimRules {
pattern = List("(最近|近期|这段时间)".regex),
prod = {
case (options, _) =>
val from = cycleNth(Day, 0, Day)
val to = cycleNth(Day, 2, Day)
val fuzzyValue = options.timeOptions.durationFuzzyValue - 1
val (from, to) = if (options.timeOptions.recentInFuture && options.timeOptions.alwaysInFuture) {
(cycleNth(Day, 0, Day), cycleNth(Day, fuzzyValue, Day))
} else {
(cycleNth(Day, -fuzzyValue, Day), cycleNth(Day, 0, Day))
}

for (td <- interval(Open, from, to, options.timeOptions.beforeEndOfInterval)) yield {
Token(Date, td.copy(hint = Hint.UncertainRecent))
}
Expand Down

0 comments on commit d413f70

Please sign in to comment.