Skip to content

Commit

Permalink
- revert #248
Browse files Browse the repository at this point in the history
- 复用PartOfDay的beforeEndOfInterval重做
  • Loading branch information
du00cs committed Dec 26, 2024
1 parent d6e38f8 commit 6e85a0c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,21 @@ package object time {
// 逻辑比较混乱,待收集到问题再处理
val happened =
td.timePred match {
// 下午3点问“下午”, 12号 04:30 问 12号凌晨,还需要停留在12号
case _: TimeIntervalsPredicate | IntersectTimePredicate(TimeIntervalsPredicate(_, _, _, _), _) =>
val beforeEndOfInterval = td.timePred match {
case TimeIntervalsPredicate(_, _, _, b) => b
case IntersectTimePredicate(TimeIntervalsPredicate(_, _, _, b), _) => b
}
val g = if (td.timeGrain >= Grain.Day) td.timeGrain else Grain.NoGrain
if (!beforeEndOfInterval) timeBefore(ahead, refTime, g)
else endBefore(ahead, refTime, g)
case _: TimeDatePredicate | _: IntersectTimePredicate =>
// 若参考时间是2013/2/12 04:30,在alwaysInFuture情况下
// 1. 过了一部分还需要再出的,12号 => 2/12,2月 => 2013/2
// 2. 问4点,需要给出 16:00
val g = if (td.timeGrain >= Grain.Day) td.timeGrain else Grain.NoGrain
timeBefore(ahead, refTime, g)
case TimeIntervalsPredicate(_, _, _, beforeEndOfInterval) =>
val g = if (td.timeGrain >= Grain.Day) td.timeGrain else Grain.NoGrain
if (!beforeEndOfInterval) timeBefore(ahead, refTime, g)
else endBefore(ahead, refTime, g)
case _ => false
}
if (happened || td.notImmediate && timeIntersect(ahead)(refTime).nonEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,15 @@ object Examples extends DimExamples {
),
List("凌晨")
),
(
localDateTimeInterval(
LocalDateTime.of(2013, 2, 12, 0, 0, 0),
LocalDateTime.of(2013, 2, 12, 6, 0, 0),
Hour,
partOfDay = "凌晨"
),
List("12号凌晨")
),
(
localDateTimeInterval(
LocalDateTime.of(2013, 2, 13, 15, 0, 0),
Expand Down

0 comments on commit 6e85a0c

Please sign in to comment.