统一代码风格

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

View File

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