need to work on standard date formatting

This commit is contained in:
Jeff Carr 2025-03-12 13:18:30 -05:00
parent e640db7eb6
commit 0288d05f2d
1 changed files with 39 additions and 0 deletions

39
date.go Normal file
View File

@ -0,0 +1,39 @@
package tree
import (
"time"
)
// TODO; let the user choose the date format
func MakeDatestamp(t time.Time) string {
/*
// Get system locale from the environment
locale := os.Getenv("LANG")
if locale == "" {
locale = "en_US" // Default to English (US) if not set
}
// Parse the language tag
tag, err := language.Parse(locale)
if err != nil {
log.Fatalf("Invalid locale: %v", err)
}
// Create a date formatter
formatter := date.NewFormatter(date.OrderDefault, catalog.NewBuilder())
// Get the current timestamp
now := time.Now()
// Format the date based on the locale
p := message.NewPrinter(tag)
formattedDate := formatter.Format(tag, now)
// Print the formatted date
fmt.Println("Formatted Date:", formattedDate)
// Alternative: Use predefined time formats
fmt.Println("Localized Date (fallback):", p.Sprintf("%v", now.Format(time.RFC1123)))
*/
return t.Format(time.RFC1123)
}