aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-01-20 23:39:48 +0700
committerShulhan <ms@kilabit.info>2023-02-22 23:33:55 +0700
commitae6a01970457d4d080aa98006312bbb95f44569c (patch)
treec17ab78607d4d19c427067879c9222b6db1ad221
parent2efa4a559daa9132d3a06dbd1b4656baa07bffd8 (diff)
downloadpakakeh.go-ae6a01970457d4d080aa98006312bbb95f44569c.tar.xz
lib/time: add global variable Now as function
The Now variable return the current local time. Unlike standard library, this is a variable that can be override to mock the current time during testing.
-rw-r--r--lib/time/time.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/time/time.go b/lib/time/time.go
index 66fd02e2..5d2602ba 100644
--- a/lib/time/time.go
+++ b/lib/time/time.go
@@ -10,6 +10,13 @@ import (
"time"
)
+// Now returns the current local time.
+// Unlike standard library, this is a variable that can be override to mock
+// the current time during testing.
+var Now = func() time.Time {
+ return time.Now()
+}
+
var (
ShortDayNames = []string{
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",