Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2026-02-25 16:08:15 +08:00
parent cab8ea3a5d
commit 6f31b0990d
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -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