print timezone on some dates.

This commit is contained in:
fiatjaf
2024-10-12 09:10:16 -03:00
parent f55da46b54
commit 45c19052d0
3 changed files with 2 additions and 14 deletions

View File

@@ -68,7 +68,7 @@ func grabData(ctx context.Context, code string) (Data, error) {
data.neventNaked, _ = nip19.EncodeEvent(event.ID, nil, event.PubKey)
data.naddr = ""
data.naddrNaked = ""
data.createdAt = time.Unix(int64(event.CreatedAt), 0).Format("2006-01-02 15:04:05")
data.createdAt = time.Unix(int64(event.CreatedAt), 0).Format("2006-01-02 15:04:05 MST")
if event.Kind >= 30000 && event.Kind < 40000 {
if d := event.Tags.GetFirst([]string{"d", ""}); d != nil {

View File

@@ -202,7 +202,7 @@ func (ee EnhancedEvent) Nevent() string {
}
func (ee EnhancedEvent) CreatedAtStr() string {
return time.Unix(int64(ee.Event.CreatedAt), 0).Format("2006-01-02 15:04:05")
return time.Unix(int64(ee.Event.CreatedAt), 0).Format("2006-01-02 15:04:05 MST")
}
func (ee EnhancedEvent) ModifiedAtStr() string {

View File

@@ -409,18 +409,6 @@ func limitAt[V any](list []V, n int) []V {
return list[0:n]
}
func humanDate(createdAt nostr.Timestamp) string {
ts := createdAt.Time()
now := time.Now()
if ts.Before(now.AddDate(0, -9, 0)) {
return ts.UTC().Format("02 Jan 2006")
} else if ts.Before(now.AddDate(0, 0, -6)) {
return ts.UTC().Format("Jan _2")
} else {
return ts.UTC().Format("Mon, Jan _2 15:04 UTC")
}
}
func maxIndex(slice []int) int {
maxIndex := -1
maxVal := 0