mirror of
https://gitee.com/dromara/carbon.git
synced 2024-11-29 18:57:37 +08:00
统一代码风格
This commit is contained in:
parent
054dda855d
commit
f0248f3a7b
@ -136,7 +136,7 @@ type Carbon struct {
|
||||
Error error
|
||||
}
|
||||
|
||||
// String 实现 String 接口
|
||||
// String 实现 Stringer 接口
|
||||
func (c Carbon) String() string {
|
||||
if c.IsZero() {
|
||||
return ""
|
||||
@ -167,7 +167,7 @@ func Now() Carbon {
|
||||
|
||||
// Tomorrow 明天
|
||||
func (c Carbon) Tomorrow() Carbon {
|
||||
if c.Time.IsZero() {
|
||||
if c.IsZero() {
|
||||
c.Time = time.Now().AddDate(0, 0, 1)
|
||||
} else {
|
||||
c.Time = c.Time.AddDate(0, 0, 1)
|
||||
|
@ -175,7 +175,6 @@ func (c Carbon) Compare(operator string, t Carbon) bool {
|
||||
case "<=":
|
||||
return c.Lte(t)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -183,9 +183,7 @@ func (c Carbon) DiffForHumans(arg ...Carbon) string {
|
||||
diff = 0
|
||||
return c.Lang.translate(unit, diff)
|
||||
}
|
||||
|
||||
translation := c.Lang.translate(unit, diff)
|
||||
|
||||
if c.Lt(end) && len(arg) == 0 {
|
||||
return strings.Replace(c.Lang.resources["ago"], "%s", translation, 1)
|
||||
}
|
||||
@ -198,6 +196,5 @@ func (c Carbon) DiffForHumans(arg ...Carbon) string {
|
||||
if c.Gt(end) && len(arg) > 0 {
|
||||
return strings.Replace(c.Lang.resources["after"], "%s", translation, 1)
|
||||
}
|
||||
|
||||
return translation
|
||||
}
|
||||
|
@ -64,7 +64,6 @@ func (lang *Language) SetResources(resources map[string]string) {
|
||||
lang.resources = resources
|
||||
return
|
||||
}
|
||||
|
||||
for k, v := range resources {
|
||||
if _, ok := lang.resources[k]; ok {
|
||||
lang.resources[k] = v
|
||||
|
Loading…
Reference in New Issue
Block a user