refactor(ui): use lctime for date formatting

Amolith created

Assisted-by: Claude Opus 4.5 via Crush

Change summary

go.mod                |  1 +
go.sum                |  2 ++
internal/ui/styles.go | 26 +++-----------------------
3 files changed, 6 insertions(+), 23 deletions(-)

Detailed changes

go.mod 🔗

@@ -10,6 +10,7 @@ require (
 	github.com/charmbracelet/huh/spinner v0.0.0-20251215014908-6f7d32faaff3
 	github.com/charmbracelet/lipgloss v1.1.0
 	github.com/google/uuid v1.6.0
+	github.com/klauspost/lctime v0.1.0
 	github.com/spf13/cobra v1.10.2
 	github.com/zalando/go-keyring v0.2.6
 )

go.sum 🔗

@@ -79,6 +79,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
 github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/klauspost/lctime v0.1.0 h1:nINsuFc860M9cyYhT6vfg6U1USh7kiVBj/s/2b04U70=
+github.com/klauspost/lctime v0.1.0/go.mod h1:OwdMhr8tbQvusAsnilqkkgDQqivWlqyg0w5cfXkLiDk=
 github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
 github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
 github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=

internal/ui/styles.go 🔗

@@ -6,10 +6,10 @@
 package ui
 
 import (
-	"os"
 	"time"
 
 	"github.com/charmbracelet/lipgloss"
+	"github.com/klauspost/lctime"
 )
 
 // Terminal output styles using ANSI colors for broad compatibility.
@@ -21,28 +21,8 @@ var (
 	Bold    = lipgloss.NewStyle().Bold(true)
 )
 
-// dateFormat holds the date format string derived from locale.
-var dateFormat = initDateFormat()
-
-// initDateFormat determines the date format based on LC_TIME or LANG.
-func initDateFormat() string {
-	locale := os.Getenv("LC_TIME")
-	if locale == "" {
-		locale = os.Getenv("LANG")
-	}
-
-	// US English uses month-first; most other locales use day-first or ISO
-	switch {
-	case len(locale) >= 2 && locale[:2] == "en" && len(locale) >= 5 && locale[3:5] == "US":
-		return "01/02/2006"
-	case len(locale) >= 2 && locale[:2] == "en":
-		return "02/01/2006"
-	default:
-		return "2006-01-02" // ISO 8601 as sensible default
-	}
-}
-
 // FormatDate formats a time.Time as a date string using the user's locale.
+// Locale is auto-detected from LC_TIME, LC_ALL, or LANG environment variables.
 func FormatDate(t time.Time) string {
-	return t.Format(dateFormat)
+	return lctime.Strftime("%x", t)
 }