mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-14 11:31:33 +08:00
rabbitmq log datetime support
This commit is contained in:
parent
ab345927d5
commit
2cbb9d374c
30
parseany.go
30
parseany.go
@ -491,6 +491,35 @@ iterRunes:
|
|||||||
}
|
}
|
||||||
p.stateTime = timeStart
|
p.stateTime = timeStart
|
||||||
break iterRunes
|
break iterRunes
|
||||||
|
case ':':
|
||||||
|
p.link++
|
||||||
|
if p.link == 2 {
|
||||||
|
// we need to find if this was 4 digits, aka year
|
||||||
|
// or 2 digits which makes it ambiguous year/day
|
||||||
|
length := i - (p.moi + p.molen + 2)
|
||||||
|
if length == 4 {
|
||||||
|
p.yearlen = 4
|
||||||
|
p.set(p.yeari, "2006")
|
||||||
|
// We now also know that part1 was the day
|
||||||
|
p.dayi = 0
|
||||||
|
p.daylen = p.part1Len
|
||||||
|
p.setDay()
|
||||||
|
} else if length == 2 {
|
||||||
|
// We have no idea if this is
|
||||||
|
// yy-mon-dd OR dd-mon-yy
|
||||||
|
//
|
||||||
|
// We are going to ASSUME (bad, bad) that it is dd-mon-yy which is a horible assumption
|
||||||
|
p.ambiguousMD = true
|
||||||
|
p.yearlen = 2
|
||||||
|
p.set(p.yeari, "06")
|
||||||
|
// We now also know that part1 was the day
|
||||||
|
p.dayi = 0
|
||||||
|
p.daylen = p.part1Len
|
||||||
|
p.setDay()
|
||||||
|
}
|
||||||
|
p.stateTime = timeStart
|
||||||
|
break iterRunes
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case dateDigitSlash:
|
case dateDigitSlash:
|
||||||
@ -1839,6 +1868,7 @@ type parser struct {
|
|||||||
datestr string
|
datestr string
|
||||||
fullMonth string
|
fullMonth string
|
||||||
skip int
|
skip int
|
||||||
|
link int
|
||||||
extra int
|
extra int
|
||||||
part1Len int
|
part1Len int
|
||||||
yeari int
|
yeari int
|
||||||
|
@ -532,6 +532,8 @@ var testParseFormat = []dateTest{
|
|||||||
{in: "2009-08-12T22:15:09-0700", out: "2006-01-02T15:04:05-0700"},
|
{in: "2009-08-12T22:15:09-0700", out: "2006-01-02T15:04:05-0700"},
|
||||||
// yyyy-mm-ddThh:mm:ssZ
|
// yyyy-mm-ddThh:mm:ssZ
|
||||||
{in: "2009-08-12T22:15Z", out: "2006-01-02T15:04Z"},
|
{in: "2009-08-12T22:15Z", out: "2006-01-02T15:04Z"},
|
||||||
|
|
||||||
|
{in: "8-Mar-2018::14:09:27", out: "2-Jan-2006::15:04:05"},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseLayout(t *testing.T) {
|
func TestParseLayout(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user