fix: handle the zero cases for oidc.Time
This commit is contained in:
parent
890a7f3ed4
commit
115813ee38
2 changed files with 57 additions and 0 deletions
|
@ -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())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue