added utc time functions

This commit is contained in:
ston1th 2018-09-13 15:58:24 +02:00
commit 1bdb6009cf
2 changed files with 27 additions and 5 deletions

22
time.go Normal file
View file

@ -0,0 +1,22 @@
package jwt
import "time"
// Now returns the current time in UTC Unix format
func Now() int64 {
return NewNbf(time.Now())
}
// NewNbf returns a new 'not before' date
func NewNbf(t time.Time) int64 {
return t.UTC().Unix()
}
// NewExp returns a new expiration date
func NewExp(d time.Duration) int64 {
return newExp(time.Now(), d)
}
func newExp(t time.Time, d time.Duration) int64 {
return t.UTC().Add(d).Unix()
}