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:
@@ -276,3 +276,17 @@ func parseGregorianDateKey(key string) (int, int, int) {
|
||||
fmt.Sscanf(key, "%04d-%02d-%02d", &y, &m, &d)
|
||||
return y, m, d
|
||||
}
|
||||
|
||||
func formatDateForCalendar(date, calType string) string {
|
||||
y, m, d := parseGregorianDateKey(date)
|
||||
switch calType {
|
||||
case "jalali":
|
||||
jy, jm, jd := gregorianToJalali(y, m, d)
|
||||
return fmt.Sprintf("%04d-%02d-%02d", jy, jm, jd)
|
||||
case "hijri":
|
||||
hy, hm, hd := gregorianToHijri(y, m, d)
|
||||
return fmt.Sprintf("%04d-%02d-%02d", hy, hm, hd)
|
||||
default:
|
||||
return date
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user