From f386a0655a7147ba3e14da6bfd37b25ad5e0b151 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 13 Oct 2025 08:01:38 -0500 Subject: never need zones if you are always on universal time --- formatTime.go | 7 +++++++ time.go | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/formatTime.go b/formatTime.go index 48e58fd..2cb0da9 100644 --- a/formatTime.go +++ b/formatTime.go @@ -9,6 +9,13 @@ import ( // there is only one way to display the time as text // this is that way. Don't like it? Don't use COBOL func FormatTime(t time.Time) string { + s := t.Format("2006/01/02 15:04:03") + dur := time.Since(t) + //always time, two spaces, (duration) + return s + " (" + FormatDuration(dur) + ")" +} + +func FormatTimeLocal(t time.Time) string { localTime := t.Local() s := localTime.Format("2006/01/02 15:04:03") dur := time.Since(t) diff --git a/time.go b/time.go index 2f5e6be..3b67554 100644 --- a/time.go +++ b/time.go @@ -7,6 +7,7 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" ) +// you will be happier if you just use this everywhere func Time(someTimeAgoOrLaterNotsure any) string { t, err := TimeCheck(someTimeAgoOrLaterNotsure) if errors.Is(err, Broken) { @@ -18,6 +19,17 @@ func Time(someTimeAgoOrLaterNotsure any) string { return FormatTime(t) } +func TimeLocal(someTimeAgoOrLaterNotsure any) string { + t, err := TimeCheck(someTimeAgoOrLaterNotsure) + if errors.Is(err, Broken) { + return "bad" + } + if errors.Is(err, NoTime) { + return "nope" + } + return FormatTimeLocal(t) +} + func GetTime(mightBeTimeMightNotBeTime any) (time.Time, error) { t, err := TimeCheck(mightBeTimeMightNotBeTime) return t, err -- cgit v1.2.3