fix: deliver validated AI insight responses

This commit is contained in:
2026-08-22 15:47:38 +08:00
parent ca55c2fb3d
commit 3fba4261ee
68 changed files with 6870 additions and 493 deletions

View File

@@ -119,6 +119,16 @@ func nextJalaliMonth(jy, jm int) (int, int) {
return jy, jm
}
// JalaliMonthBounds returns the Tehran-local start and inclusive end of the
// Jalali month containing at. It is shared by deterministic business rules.
func JalaliMonthBounds(at time.Time, location *time.Location) (time.Time, time.Time) {
local := at.In(location)
year, month, _ := gregorianToJalali(local.Year(), int(local.Month()), local.Day())
start := jalaliDate(year, month, 1, location)
nextYear, nextMonth := nextJalaliMonth(year, month)
return start, jalaliDate(nextYear, nextMonth, 1, location).AddDate(0, 0, -1)
}
func completePeriods(datasetStart, datasetMax time.Time, location *time.Location) []Period {
if datasetMax.Before(datasetStart) {
return nil