mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-05-05 12:22:35 +02:00
Integrated Fantastic coffie (decaffeinated) base version
This commit is contained in:
parent
2fc5535f0f
commit
94036c4831
482 changed files with 476112 additions and 0 deletions
21
service/globaltime/globaltime.go
Normal file
21
service/globaltime/globaltime.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package globaltime
|
||||
|
||||
import "time"
|
||||
|
||||
// FixedTime represent a fixed moment in time. Set this variable to anything different from the default value for
|
||||
// time.Time and the value will be returned in Now() function in place of the current time
|
||||
var FixedTime time.Time
|
||||
|
||||
// Now returns the current time (time.Now()) if no FixedTime has been set. Otherwise, it returns FixedTime.
|
||||
// Use this in place of time.Now() to allow testing w/ custom time.
|
||||
func Now() time.Time {
|
||||
if FixedTime.After(time.Time{}) {
|
||||
return FixedTime
|
||||
}
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
// Since returns the time passed since the parameter tm.
|
||||
func Since(tm time.Time) time.Duration {
|
||||
return Now().Sub(tm)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue