mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 11:51:54 +08:00
Add support for git default log date format
Support git default log date like: "Thu Apr 7 15:13:13 2005 -0700" Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
This commit is contained in:
parent
a7e601ee84
commit
99d9682a1c
23
parseany.go
23
parseany.go
@ -90,16 +90,17 @@ const (
|
||||
timeWsOffsetColonAlpha
|
||||
timeWsOffsetColon
|
||||
timeWsYear // 15
|
||||
timeWsYearOffset
|
||||
timeOffset
|
||||
timeOffsetColon
|
||||
timeAlpha
|
||||
timePeriod
|
||||
timePeriodOffset // 20
|
||||
timePeriodOffset
|
||||
timePeriodOffsetColon
|
||||
timePeriodOffsetColonWs
|
||||
timePeriodWs
|
||||
timePeriodWsAlpha
|
||||
timePeriodWsOffset // 25
|
||||
timePeriodWsOffset
|
||||
timePeriodWsOffsetWs
|
||||
timePeriodWsOffsetWsAlpha
|
||||
timePeriodWsOffsetColon
|
||||
@ -547,6 +548,7 @@ iterRunes:
|
||||
// Mon Jan _2 15:04:05 2006
|
||||
// Mon Jan _2 15:04:05 MST 2006
|
||||
// Mon Jan 02 15:04:05 -0700 2006
|
||||
// Mon Jan 02 15:04:05 2006 -0700
|
||||
// Mon Aug 10 15:44:11 UTC+0100 2015
|
||||
// Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time)
|
||||
// dateAlphaWSDigit
|
||||
@ -636,6 +638,7 @@ iterRunes:
|
||||
// Mon Jan _2 15:04:05 2006
|
||||
// Mon Jan _2 15:04:05 MST 2006
|
||||
// Mon Jan 02 15:04:05 -0700 2006
|
||||
// Mon Jan 02 15:04:05 2006 -0700
|
||||
// Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time)
|
||||
// Mon Aug 10 15:44:11 UTC+0100 2015
|
||||
// dateAlphaWsDigit
|
||||
@ -708,6 +711,7 @@ iterRunes:
|
||||
case dateAlphaWsAlpha:
|
||||
// Mon Jan _2 15:04:05 2006
|
||||
// Mon Jan 02 15:04:05 -0700 2006
|
||||
// Mon Jan 02 15:04:05 2006 -0700
|
||||
// Mon Jan _2 15:04:05 MST 2006
|
||||
// Mon Aug 10 15:44:11 UTC+0100 2015
|
||||
// Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time)
|
||||
@ -1075,6 +1079,8 @@ iterRunes:
|
||||
// 00:12:00 +00:00 UTC
|
||||
// timeWsYear
|
||||
// 00:12:00 2008
|
||||
// timeWsYearOffset
|
||||
// 00:12:00 2008 +0800
|
||||
// timeZ
|
||||
// 15:04:05.99Z
|
||||
switch r {
|
||||
@ -1100,6 +1106,17 @@ iterRunes:
|
||||
p.yeari = i
|
||||
}
|
||||
}
|
||||
case timeWsYear:
|
||||
// timeWsYearOffset
|
||||
// 00:12:00 2008 +0800
|
||||
switch r {
|
||||
case ' ':
|
||||
p.yearlen = i - p.yeari
|
||||
p.setYear()
|
||||
case '+', '-':
|
||||
p.offseti = i
|
||||
p.stateTime = timeWsYearOffset
|
||||
}
|
||||
case timeWsAlpha:
|
||||
// 06:20:00 UTC
|
||||
// 06:20:00 UTC-05
|
||||
@ -1448,6 +1465,8 @@ iterRunes:
|
||||
p.set(p.offseti, "-0700")
|
||||
case timeWsOffset:
|
||||
p.set(p.offseti, "-0700")
|
||||
case timeWsYearOffset:
|
||||
p.set(p.offseti, "-0700")
|
||||
case timeWsOffsetWs:
|
||||
// 17:57:51 -0700 2009
|
||||
// 00:12:00 +0000 UTC
|
||||
|
@ -385,6 +385,9 @@ var testInputs = []dateTest{
|
||||
{in: "1384216367111 +0000", out: "2013-11-12 00:32:47.111 +0000 UTC"},
|
||||
{in: "1384216367111222 -0000", out: "2013-11-12 00:32:47.111222 +0000 UTC"},
|
||||
{in: "1384216367111222333 +0130", out: "2013-11-12 00:32:47.111222333 +0000 UTC"},
|
||||
|
||||
// git log default date format
|
||||
{in: "Thu Apr 7 15:13:13 2005 -0700", out: "2005-04-07 22:13:13 +0000 UTC"},
|
||||
}
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user