Use ParseDate in Entry

This commit is contained in:
Dan Jones 2024-02-25 13:39:12 -06:00
commit c1b1ceb283
2 changed files with 13 additions and 8 deletions

View file

@ -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