Skip to content

Commit

Permalink
精简两个时间大小判断逻辑代码
Browse files Browse the repository at this point in the history
  • Loading branch information
gouguoyin committed Feb 2, 2021
1 parent 19b96de commit 8057789
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions final.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,19 +687,19 @@ func (c Carbon) IsTomorrow() bool {
func (c Carbon) Compare(operator string, t Carbon) bool {
switch operator {
case "=":
return c.Time.Equal(t.Time)
return c.Eq(t)
case "<>":
return !c.Time.Equal(t.Time)
return !c.Eq(t)
case "!=":
return !c.Time.Equal(t.Time)
return !c.Eq(t)
case ">":
return c.Time.After(t.Time)
return c.Gt(t)
case ">=":
return c.Time.After(t.Time) || c.Time.Equal(t.Time)
return c.Gte(t)
case "<":
return c.Time.Before(t.Time)
return c.Lt(t)
case "<=":
return c.Time.Before(t.Time) || c.Time.Equal(t.Time)
return c.Lte(t)
}

return false
Expand Down

0 comments on commit 8057789

Please sign in to comment.