need to work on standard date formatting
This commit is contained in:
parent
e640db7eb6
commit
0288d05f2d
|
@ -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)
|
||||
}
|
Loading…
Reference in New Issue