统一代码风格

This commit is contained in:
gouguoyin 2021-04-05 16:30:22 +08:00
parent 67913299fe
commit 8e5a3df707
2 changed files with 0 additions and 9 deletions

View File

@ -10,7 +10,6 @@ func (c Carbon) Constellation() string {
if len(c.Lang.resources) == 0 && c.Lang.SetLocale(defaultLocale) != nil {
return ""
}
index := -1
switch {
case c.Month() == 3 && c.Day() >= 21, c.Month() == 4 && c.Day() <= 19:
@ -40,12 +39,10 @@ func (c Carbon) Constellation() string {
default:
return ""
}
if constellations, ok := c.Lang.resources["constellations"]; ok {
slice := strings.Split(constellations, "|")
return slice[index]
}
return ""
}

View File

@ -12,21 +12,16 @@ func (c Carbon) Parse(value string) Carbon {
if c.Error != nil {
return c
}
layout := DateTimeFormat
if value == "" || value == "0" || value == "0000-00-00 00:00:00" || value == "0000-00-00" || value == "00:00:00" {
return c
}
if len(value) == 10 && strings.Count(value, "-") == 2 {
layout = DateFormat
}
if strings.Index(value, "T") == 10 {
layout = RFC3339Format
}
if _, err := strconv.ParseInt(value, 10, 64); err == nil {
switch len(value) {
case 8:
@ -35,7 +30,6 @@ func (c Carbon) Parse(value string) Carbon {
layout = ShortDateTimeFormat
}
}
return c.ParseByLayout(value, layout)
}