@@ -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)
}