mirror of
https://github.com/araddon/dateparse.git
synced 2025-01-19 19:26:09 +08:00
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:
parent
fc278d32da
commit
df9ae2e32a
19
parseany.go
19
parseany.go
@ -400,7 +400,7 @@ iterRunes:
|
|||||||
if !p.setYear() {
|
if !p.setYear() {
|
||||||
return p, unknownErr(datestr)
|
return p, unknownErr(datestr)
|
||||||
}
|
}
|
||||||
} else {
|
} else if i <= 2 {
|
||||||
p.ambiguousMD = true
|
p.ambiguousMD = true
|
||||||
if p.preferMonthFirst {
|
if p.preferMonthFirst {
|
||||||
if p.molen == 0 {
|
if p.molen == 0 {
|
||||||
@ -421,6 +421,8 @@ iterRunes:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// else this might be a unixy combined datetime of the form:
|
||||||
|
// yyyyMMddhhmmss.SSS
|
||||||
|
|
||||||
case ' ':
|
case ' ':
|
||||||
// 18 January 2018
|
// 18 January 2018
|
||||||
@ -2128,12 +2130,17 @@ iterRunes:
|
|||||||
return p, nil
|
return p, nil
|
||||||
|
|
||||||
case dateDigitDot:
|
case dateDigitDot:
|
||||||
// 2014.05
|
if len(datestr) == len("yyyyMMddhhmmss.SSS") { // 18
|
||||||
p.molen = i - p.moi
|
p.setEntireFormat([]byte("20060102150405.000"))
|
||||||
if !p.setMonth() {
|
return p, nil
|
||||||
return p, unknownErr(datestr)
|
} else {
|
||||||
|
// 2014.05
|
||||||
|
p.molen = i - p.moi
|
||||||
|
if !p.setMonth() {
|
||||||
|
return p, unknownErr(datestr)
|
||||||
|
}
|
||||||
|
return p, nil
|
||||||
}
|
}
|
||||||
return p, nil
|
|
||||||
|
|
||||||
case dateDigitDotDot:
|
case dateDigitDotDot:
|
||||||
// 03.31.1981
|
// 03.31.1981
|
||||||
|
@ -418,6 +418,8 @@ var testInputs = []dateTest{
|
|||||||
{in: "2013 May 02 11:37:55", out: "2013-05-02 11:37:55 +0000 UTC"},
|
{in: "2013 May 02 11:37:55", out: "2013-05-02 11:37:55 +0000 UTC"},
|
||||||
{in: "2013 June 02 11:37:55", out: "2013-06-02 11:37:55 +0000 UTC"},
|
{in: "2013 June 02 11:37:55", out: "2013-06-02 11:37:55 +0000 UTC"},
|
||||||
{in: "2013 December 02 11:37:55", out: "2013-12-02 11:37:55 +0000 UTC"},
|
{in: "2013 December 02 11:37:55", out: "2013-12-02 11:37:55 +0000 UTC"},
|
||||||
|
// https://github.com/araddon/dateparse/issues/143
|
||||||
|
{in: "20140722105203.364", out: "2014-07-22 10:52:03.364 +0000 UTC"},
|
||||||
// yyyy-mm-dd hh:mm:ss,000
|
// yyyy-mm-dd hh:mm:ss,000
|
||||||
{in: "2014-05-11 08:20:13,787", out: "2014-05-11 08:20:13.787 +0000 UTC"},
|
{in: "2014-05-11 08:20:13,787", out: "2014-05-11 08:20:13.787 +0000 UTC"},
|
||||||
// yyyy-mm-dd hh:mm:ss +0000
|
// yyyy-mm-dd hh:mm:ss +0000
|
||||||
|
Loading…
Reference in New Issue
Block a user