diff --git a/cmd/entries/manual.go b/cmd/entries/manual.go index ad7d1b0..323de46 100644 --- a/cmd/entries/manual.go +++ b/cmd/entries/manual.go @@ -308,15 +308,15 @@ func parseDateTime(date, timeStr, dateLayout string) (time.Time, error) { normalizedTime := normalizeAMPM(timeStr) dateTime := fmt.Sprintf("%s %s", date, normalizedTime) - if dt, err := time.ParseInLocation(dateLayout + " 3:04 PM", dateTime, time.Local); err == nil { + if dt, err := time.ParseInLocation(dateLayout + " 3:04 PM", dateTime, settings.GetDisplayTimezone()); err == nil { return dt, nil } - if dt, err := time.ParseInLocation(dateLayout + " 03:04 PM", dateTime, time.Local); err == nil { + if dt, err := time.ParseInLocation(dateLayout + " 03:04 PM", dateTime, settings.GetDisplayTimezone()); err == nil { return dt, nil } - return time.ParseInLocation(dateLayout + " 15:04", dateTime, time.Local) + return time.ParseInLocation(dateLayout + " 15:04", dateTime, settings.GetDisplayTimezone()) } func normalizeAMPM(input string) string { diff --git a/internal/settings/global_config.go b/internal/settings/global_config.go index 07da812..72700f4 100644 --- a/internal/settings/global_config.go +++ b/internal/settings/global_config.go @@ -92,8 +92,8 @@ func (gc *GlobalConfig) Save() error { return nil } -// getDisplayTimezone returns the user's configured timezone or local timezone as fallback -func getDisplayTimezone() *time.Location { +// GetDisplayTimezone returns the user's configured timezone or local timezone as fallback +func GetDisplayTimezone() *time.Location { cfg, err := LoadGlobalConfig() if err != nil || cfg.Timezone == "" { return time.Local @@ -109,7 +109,7 @@ func getDisplayTimezone() *time.Location { // toDisplayTime converts a UTC time to the user's display timezone func toDisplayTime(t time.Time) time.Time { - return t.In(getDisplayTimezone()) + return t.In(GetDisplayTimezone()) } func FormatTime(t time.Time) string {