24 lines
466 B
Go
24 lines
466 B
Go
// Copyright (C) 2025 Marius Schellenberger
|
|
|
|
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()
|
|
}
|