Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: https://github.com/siyuan-note/siyuan/issues/16963

Daniel6f31b0990d3d
diff --git a/kernel/av/filter.go b/kernel/av/filter.go
index 52d185f818..16fe4df4d5 100644
--- a/kernel/av/filter.go
+++ b/kernel/av/filter.go
@@ -978,10 +978,10 @@ func calcRelativeTimeRegion(count int, unit RelativeDateUnit, direction Relative
// 结束时间:本周的周日
end = time.Date(now.Year(), now.Month(), now.Day()-weekday+7, 23, 59, 59, 999999999, now.Location())
case RelativeDateDirectionAfter:
- // 开始时间:本周的周日
- start = time.Date(now.Year(), now.Month(), now.Day()-weekday+7, 23, 59, 59, 999999999, now.Location())
- // 结束时间:开始时间加上 count*7 天
- end = start.AddDate(0, 0, count*7)
+ // 开始时间:本周的周一加上 count*7 天
+ start = time.Date(now.Year(), now.Month(), now.Day()-weekday+1, 0, 0, 0, 0, now.Location()).AddDate(0, 0, count*7)
+ // 结束时间:开始时间的周日
+ end = time.Date(start.Year(), start.Month(), start.Day()-int(start.Weekday())+7, 23, 59, 59, 999999999, now.Location())
}
case RelativeDateUnitMonth:
switch direction {
@@ -996,10 +996,10 @@ func calcRelativeTimeRegion(count int, unit RelativeDateUnit, direction Relative
// 结束时间:下个月的 1 号减去 1 纳秒
end = time.Date(now.Year(), now.Month()+1, 1, 0, 0, 0, 0, now.Location()).Add(-time.Nanosecond)
case RelativeDateDirectionAfter:
- // 开始时间:下个月的 1 号减去 1 纳秒
- start = time.Date(now.Year(), now.Month()+1, 1, 0, 0, 0, 0, now.Location()).Add(-time.Nanosecond)
- // 结束时间:开始时间加上 count 个月
- end = start.AddDate(0, count, 0)
+ // 开始时间:count 个月后的 1 号
+ start = time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location()).AddDate(0, count, 0)
+ // 结束时间:开始时间的下个月的 1 号减去 1 纳秒
+ end = time.Date(start.Year(), start.Month()+1, 1, 0, 0, 0, 0, now.Location()).Add(-time.Nanosecond)
}
case RelativeDateUnitYear:
switch direction {
@@ -1014,10 +1014,10 @@ func calcRelativeTimeRegion(count int, unit RelativeDateUnit, direction Relative
// 结束时间:明年的 1 月 1 号减去 1 纳秒
end = time.Date(now.Year()+1, 1, 1, 0, 0, 0, 0, now.Location()).Add(-time.Nanosecond)
case RelativeDateDirectionAfter:
- // 开始时间:今年的 12 月 31 号
- start = time.Date(now.Year(), 12, 31, 23, 59, 59, 999999999, now.Location())
- // 结束时间:开始时间加上 count 年
- end = start.AddDate(count, 0, 0)
+ // 开始时间:count 年后的 1 月 1 号
+ start = time.Date(now.Year(), 1, 1, 0, 0, 0, 0, now.Location()).AddDate(count, 0, 0)
+ // 结束时间:开始时间的 count+1 年的 1 月 1 号减去 1 纳秒
+ end = time.Date(start.Year()+1, 1, 1, 0, 0, 0, 0, now.Location()).Add(-time.Nanosecond)
}
}
return