diff options
| author | Shulhan <ms@kilabit.info> | 2023-01-20 23:39:48 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-02-22 23:33:55 +0700 |
| commit | ae6a01970457d4d080aa98006312bbb95f44569c (patch) | |
| tree | c17ab78607d4d19c427067879c9222b6db1ad221 /lib/time/time.go | |
| parent | 2efa4a559daa9132d3a06dbd1b4656baa07bffd8 (diff) | |
| download | pakakeh.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.
Diffstat (limited to 'lib/time/time.go')
| -rw-r--r-- | lib/time/time.go | 7 |
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", |
