summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-13 08:01:38 -0500
committerJeff Carr <[email protected]>2025-10-13 08:01:38 -0500
commitf386a0655a7147ba3e14da6bfd37b25ad5e0b151 (patch)
tree59b7942732b54b730354fbb97c173f2bd07b53e8
parent114f34291f856f61f9aa3089952862bea4d50dd0 (diff)
never need zones if you are always on universal time
-rw-r--r--formatTime.go7
-rw-r--r--time.go12
2 files changed, 19 insertions, 0 deletions
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