Skip to content

Commit

Permalink
imp: 最近一周输出范围由本周改为最近7天 (#211)
Browse files Browse the repository at this point in the history
Co-authored-by: zhangsonglei <[email protected]>
  • Loading branch information
zhangsonglei and zhangsonglei authored Jan 31, 2024
1 parent db423a0 commit e358bbe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ trait Rules extends DimRules {
case Week => (reset(Week) _ >>> tt)(td)
case _ => tt(td)
}
} else if (s != "" && g == Week) { // 最?近一周,改为最近7天。
cycleN(notImmediate = false, Day, 7 * v).map(t => tt(t.at(Hint.Recent)))
} else tt(cycleNth(g, 0))
case "" | "" | "之前" | "往前" | "向前" | "过去" | "过去" =>
if (s == "" && (g == Day || g == Year)) None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ApiTest extends UnitSpec {

it("should date") {
val options = testOptions.copy(targets = Set(Numeral, Time, Duration, Date), full = false)
println(Api.analyze("一年前的今天", testContext, options))
println(Api.analyze("最近一周", testContext, options))
}

it("should age") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,15 @@ object Examples extends DimExamples {
Minute
),
List("未来一刻钟", "之后一刻钟", "向后一刻钟", "往后一刻钟", "一刻钟以内")
)
),
(
localDateTimeInterval(
LocalDateTime.of(2013, 2, 12, 0, 0, 0),
LocalDateTime.of(2013, 2, 19, 0, 0, 0),
Day
),
List("最近一周", "最近一星期", "近七天")
)
)

val weeks = List(
Expand Down

0 comments on commit e358bbe

Please sign in to comment.