display date in user's selected calendar on main menu and reports
buildStatusText and buildDailyReport now use formatDateForCalendar to convert the stored Gregorian date to the user's calendar type (jalali/hijri/gregorian).
This commit is contained in:
@@ -350,7 +350,6 @@ func (h *Handler) handleStart(msg *tgbotapi.Message) {
|
||||
return
|
||||
}
|
||||
slog.Info("start", "user_id", user.ID, "chat_id", msg.Chat.ID)
|
||||
h.sendText(msg.Chat.ID, "We hope you have a happy day working.")
|
||||
menu := tgbotapi.NewMessage(msg.Chat.ID, h.buildStatusText(msg.Chat.ID))
|
||||
menu.ReplyMarkup = mainKeyboard()
|
||||
h.Bot.Send(menu)
|
||||
@@ -1224,7 +1223,7 @@ func (h *Handler) buildStatusText(chatID int64) string {
|
||||
return "Welcome. Choose an action:"
|
||||
}
|
||||
|
||||
text := fmt.Sprintf("Today: %s", day.Date)
|
||||
text := fmt.Sprintf("Today: %s", formatDateForCalendar(day.Date, user.Calendar))
|
||||
|
||||
if day.IsDayOff {
|
||||
text += "\nDay Off"
|
||||
@@ -1277,16 +1276,16 @@ func (h *Handler) buildDailyReport(user *db.User, day *db.Day, events []db.Event
|
||||
|
||||
if len(events) == 0 {
|
||||
if day.IsDayOff {
|
||||
return fmt.Sprintf("%s - Day Off", day.Date)
|
||||
return fmt.Sprintf("%s - Day Off", formatDateForCalendar(day.Date, user.Calendar))
|
||||
}
|
||||
return fmt.Sprintf("%s - No events recorded.", day.Date)
|
||||
return fmt.Sprintf("%s - No events recorded.", formatDateForCalendar(day.Date, user.Calendar))
|
||||
}
|
||||
|
||||
y, m, d := parseGregorianDateKey(day.Date)
|
||||
dayStart := time.Date(y, time.Month(m), d, 0, 0, 0, 0, loc).Unix()
|
||||
dayEnd := time.Date(y, time.Month(m), d, 23, 59, 59, 0, loc).Unix()
|
||||
totals := ComputeDailyTotals(events, day.MinBreakThreshold, dayStart, dayEnd)
|
||||
lines := fmt.Sprintf("Report for %s", day.Date)
|
||||
lines := fmt.Sprintf("Report for %s", formatDateForCalendar(day.Date, user.Calendar))
|
||||
if day.IsDayOff {
|
||||
lines += "\nDay Off: Yes"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user