File: time.go

package info (click to toggle)
golang-github-protonmail-gopenpgp-v3 3.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,028 kB
  • sloc: sh: 87; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 442 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package crypto

import (
	"time"
)

// Clock is a function that returns a timestamp.
type Clock func() time.Time

// NewConstantClock returns a Clock, which always returns unixTime.
func NewConstantClock(unixTime int64) Clock {
	return func() time.Time {
		return time.Unix(unixTime, 0)
	}
}

// ZeroClock returns a Clock, which always returns the zero time.Time.
func ZeroClock() Clock {
	return func() time.Time {
		return time.Time{}
	}
}