mirror of
https://gitee.com/dromara/carbon.git
synced 2024-12-02 04:07:36 +08:00
统一代码风格
This commit is contained in:
parent
67913299fe
commit
8e5a3df707
@ -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 ""
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user