From 67eae5ffa3b4c3bd5dd31a22c55d71fb7f81f74e Mon Sep 17 00:00:00 2001 From: db123 Date: Wed, 24 Jun 2026 10:32:17 +0330 Subject: [PATCH] fix export timezone and calendar month title - Export now uses time.Now().In(loc) for year/month so users in positive UTC offsets get the correct month - Export month title for Jalali/Hijri now correctly converts the first day of the Gregorian month to the target calendar instead of using the Gregorian month index to look up target month names --- internal/bot/export.go | 6 ++++-- internal/bot/handlers.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/bot/export.go b/internal/bot/export.go index 3757d9a..519f152 100644 --- a/internal/bot/export.go +++ b/internal/bot/export.go @@ -79,9 +79,11 @@ func GenerateMonthlyReport(store *db.Store, userID int64, timezone, accent, cale var monthName string switch calendar { case "jalali": - monthName = fmt.Sprintf("%s %d", jalaliMonthNames[month-1], year) + jy, jm, _ := gregorianToJalali(year, int(month), 1) + monthName = fmt.Sprintf("%s %d", jalaliMonthNames[jm-1], jy) case "hijri": - monthName = fmt.Sprintf("%s %d", hijriMonthNames[month-1], year) + hy, hm, _ := gregorianToHijri(year, int(month), 1) + monthName = fmt.Sprintf("%s %d", hijriMonthNames[hm-1], hy) default: monthName = time.Date(year, month, 1, 0, 0, 0, 0, time.UTC).Format("January 2006") } diff --git a/internal/bot/handlers.go b/internal/bot/handlers.go index 3d7b51a..6b58c5c 100644 --- a/internal/bot/handlers.go +++ b/internal/bot/handlers.go @@ -1240,7 +1240,8 @@ func (h *Handler) handleExport(msg *tgbotapi.Message) { h.sendText(msg.Chat.ID, "Error loading profile") return } - now := time.Now() + loc, _ := time.LoadLocation(user.Timezone) + now := time.Now().In(loc) slog.Info("export", "user_id", user.ID, "year", now.Year(), "month", now.Month()) data, err := GenerateMonthlyReport(h.DB, user.ID, user.Timezone, user.ExportAccent, user.Calendar, now.Year(), now.Month()) if err != nil { @@ -1268,7 +1269,8 @@ func (h *Handler) exportCallback(chatID int64, msgID int, callbackID string) { h.Bot.Send(edit) return } - now := time.Now() + loc, _ := time.LoadLocation(user.Timezone) + now := time.Now().In(loc) slog.Info("export", "user_id", user.ID, "year", now.Year(), "month", now.Month()) data, err := GenerateMonthlyReport(h.DB, user.ID, user.Timezone, user.ExportAccent, user.Calendar, now.Year(), now.Month()) if err != nil {