Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/entries/manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions internal/settings/global_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down