added utc time functions
This commit is contained in:
parent
fb52ae4a30
commit
1bdb6009cf
2 changed files with 27 additions and 5 deletions
22
time.go
Normal file
22
time.go
Normal 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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue