Skip to content

Commit 3cf2b68

Browse files
author
Matthew
committed
fix(time): check explicitly for a time.ParseError
1 parent 49ce800 commit 3cf2b68

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

time/time.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (t *Time) MarshalJSON() ([]byte, error) {
2727
// The time is expected to be in Deis' datetime format.
2828
func (t *Time) UnmarshalText(data []byte) (err error) {
2929
tt, err := time.Parse(DeisDatetimeFormat, string(data))
30-
if err != nil {
30+
if _, ok := err.(*time.ParseError); ok {
3131
tt, err = time.Parse(PyOpenSSLTimeDateTimeFormat, string(data))
3232
}
3333
*t = Time{tt}
@@ -39,7 +39,7 @@ func (t *Time) UnmarshalText(data []byte) (err error) {
3939
func (t *Time) UnmarshalJSON(data []byte) (err error) {
4040
// Fractional seconds are handled implicitly by Parse.
4141
tt, err := time.Parse(`"`+DeisDatetimeFormat+`"`, string(data))
42-
if err != nil {
42+
if _, ok := err.(*time.ParseError); ok {
4343
tt, err = time.Parse(`"`+PyOpenSSLTimeDateTimeFormat+`"`, string(data))
4444
}
4545
*t = Time{tt}

0 commit comments

Comments
 (0)