✨ Use ParseDate in Entry
This commit is contained in:
parent
96c3b2ff30
commit
c1b1ceb283
2 changed files with 13 additions and 8 deletions
|
|
@ -109,12 +109,9 @@ func (m *Entry) UnmarshalText(in []byte) error {
|
|||
if date == "" {
|
||||
return ErrorMissingDate
|
||||
}
|
||||
d, e := time.Parse(time.RFC3339, date)
|
||||
d, e := tools.ParseDate(date)
|
||||
if e != nil {
|
||||
d, e = time.Parse(DateFormat, date)
|
||||
if e != nil {
|
||||
return newParsingError(e)
|
||||
}
|
||||
return newParsingError(e)
|
||||
}
|
||||
m.Date = d
|
||||
|
||||
|
|
@ -270,7 +267,7 @@ func (e *Entry) UnmarshalJSON(in []byte) error {
|
|||
if (!ok || dates == "") && !e.skipMissing {
|
||||
return ErrorMissingDate
|
||||
}
|
||||
date, err := time.Parse(time.RFC3339, dates)
|
||||
date, err := tools.ParseDate(dates)
|
||||
if err != nil && !e.skipMissing {
|
||||
return newParsingError(err)
|
||||
}
|
||||
|
|
@ -280,7 +277,7 @@ func (e *Entry) UnmarshalJSON(in []byte) error {
|
|||
if m.Key == "title" || m.Key == "date" {
|
||||
continue
|
||||
} else if vs, ok := m.Value.(string); ok {
|
||||
if vd, err := time.Parse(time.RFC3339, vs); err == nil {
|
||||
if vd, err := tools.ParseDate(vs); err == nil {
|
||||
m.Value = vd
|
||||
} else {
|
||||
m.Value = vs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue