fix: handle the zero cases for oidc.Time

This commit is contained in:
Tim Möhlmann 2023-03-20 14:56:06 +02:00 committed by Tim Möhlmann
parent 890a7f3ed4
commit 115813ee38
2 changed files with 57 additions and 0 deletions

View file

@ -173,10 +173,16 @@ func NewEncoder() *schema.Encoder {
type Time int64
func (ts Time) AsTime() time.Time {
if ts == 0 {
return time.Time{}
}
return time.Unix(int64(ts), 0)
}
func FromTime(tt time.Time) Time {
if tt.IsZero() {
return 0
}
return Time(tt.Unix())
}