Incorporate support for yyyymmddhhmmss.SSS

Incorporate PR https://github.com/araddon/dateparse/pull/144 from
https://github.com/dferstay to fix
https://github.com/araddon/dateparse/issues/143
This commit is contained in:
Klondike Dragon
2023-12-12 23:19:35 -07:00
parent fc278d32da
commit df9ae2e32a
2 changed files with 15 additions and 6 deletions

View File

@@ -400,7 +400,7 @@ iterRunes:
if !p.setYear() {
return p, unknownErr(datestr)
}
} else {
} else if i <= 2 {
p.ambiguousMD = true
if p.preferMonthFirst {
if p.molen == 0 {
@@ -421,6 +421,8 @@ iterRunes:
}
}
}
// else this might be a unixy combined datetime of the form:
// yyyyMMddhhmmss.SSS
case ' ':
// 18 January 2018
@@ -2128,12 +2130,17 @@ iterRunes:
return p, nil
case dateDigitDot:
// 2014.05
p.molen = i - p.moi
if !p.setMonth() {
return p, unknownErr(datestr)
if len(datestr) == len("yyyyMMddhhmmss.SSS") { // 18
p.setEntireFormat([]byte("20060102150405.000"))
return p, nil
} else {
// 2014.05
p.molen = i - p.moi
if !p.setMonth() {
return p, unknownErr(datestr)
}
return p, nil
}
return p, nil
case dateDigitDotDot:
// 03.31.1981