Skip to content

Commit

Permalink
util/types: log timestamp error (pingcap#2336)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored Dec 28, 2016
1 parent 7c87b92 commit 5e60397
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions util/types/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (t Time) String() string {

// IsZero returns a boolean indicating whether the time is equal to ZeroTime.
func (t Time) IsZero() bool {
return isZero(t.Time)
return compareTime(t.Time, ZeroTime) == 0
}

const numberFormat = "%Y%m%d%H%i%s"
Expand Down Expand Up @@ -1158,18 +1158,14 @@ func checkMonthDay(year, month, day int) error {
return nil
}

func isZero(t TimeInternal) bool {
return t.Year() == 0 && t.Month() == 0 && t.Day() == 0 &&
t.Hour() == 0 && t.Minute() == 0 && t.Second() == 0
}

func checkTimestampType(t TimeInternal) error {
if isZero(t) {
if compareTime(t, ZeroTime) == 0 {
return nil
}

t1, err := t.GoTime()
if err != nil {
log.Infof("checkTimestampType failed, t=%v", t)
return errors.Trace(err)
}

Expand Down

0 comments on commit 5e60397

Please sign in to comment.