fix: deliver validated AI insight responses
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user