summaryrefslogtreecommitdiff
path: root/since.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-12 03:32:26 -0500
committerJeff Carr <[email protected]>2025-10-12 03:32:26 -0500
commitaff745937b2c936f87cc48b82d0725f662bb1e30 (patch)
tree374d37a352bb7e90f515db79bf7b41ea316c582b /since.go
parenta32b88646c02fd785687cd2a498b56410e62b2cd (diff)
Standard Time(). Perfect place for this. I am pleased.
Diffstat (limited to 'since.go')
-rw-r--r--since.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/since.go b/since.go
index 48f8575..3be2e5a 100644
--- a/since.go
+++ b/since.go
@@ -19,13 +19,14 @@ func Since(aLongTimeAgo any) string {
return s
}
-func GetSince(aLongTimeAgo any) (time.Duration, error) {
- return time.Second, NoTime
-}
-
// returns a human readable duration
// also returns errors
-func SinceCheck(maybeTime any) (string, error) {
+func SinceCheck(mightBeRecently any) (string, error) {
+ dur, err := GetSince(mightBeRecently)
+ return FormatDuration(dur), err
+}
+
+func GetSince(maybeTime any) (time.Duration, error) {
var t time.Time
var err error
@@ -52,11 +53,8 @@ func SinceCheck(maybeTime any) (string, error) {
err = errors.Join(err, NoTime)
}
if err != nil {
- return "", err
+ return time.Since(t), err
}
- dur := time.Since(t)
- s := FormatDuration(dur)
-
- return s, nil
+ return time.Since(t), nil
}