fix: handle the zero cases for oidc.Time

This commit is contained in:
Tim Möhlmann 2023-03-20 14:56:06 +02:00
parent 88aab28603
commit 9c7bcae539
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())
}