fix: use local time for timestamps

Display timestamps such as when a status was created using local time.
This commit is contained in:
Dan Anglin 2024-02-24 11:22:57 +00:00
parent 427ad5daf5
commit 6f1879eeba
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638
3 changed files with 11 additions and 2 deletions

View file

@ -96,7 +96,7 @@ func (a Account) String() string {
utilities.Header("ACCOUNT ID:"), utilities.Header("ACCOUNT ID:"),
a.ID, a.ID,
utilities.Header("JOINED ON:"), utilities.Header("JOINED ON:"),
a.CreatedAt.Format("02 Jan 2006"), utilities.FormatDate(a.CreatedAt),
utilities.Header("STATS:"), utilities.Header("STATS:"),
a.FollowersCount, a.FollowersCount,
a.FollowingCount, a.FollowingCount,

View file

@ -186,7 +186,7 @@ func (s Status) String() string {
utilities.Header("STATUS ID:"), utilities.Header("STATUS ID:"),
s.ID, s.ID,
utilities.Header("CREATED AT:"), utilities.Header("CREATED AT:"),
s.CreatedAt.Format("02 Jan 2006, 03:04"), utilities.FormatTime(s.CreatedAt),
utilities.Header("STATS:"), utilities.Header("STATS:"),
s.RebloggsCount, s.RebloggsCount,
s.FavouritesCount, s.FavouritesCount,

View file

@ -2,6 +2,7 @@ package utilities
import ( import (
"strings" "strings"
"time"
"unicode" "unicode"
"golang.org/x/net/html" "golang.org/x/net/html"
@ -54,3 +55,11 @@ func WrapLine(line, separator string, charLimit int) string {
func Header(text string) string { func Header(text string) string {
return boldblue + text + reset return boldblue + text + reset
} }
func FormatDate(date time.Time) string {
return date.Local().Format("02 Jan 2006")
}
func FormatTime(date time.Time) string {
return date.Local().Format("02 Jan 2006, 15:04 (MST)")
}