mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-13 05:06:36 +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
|
timeWsOffsetColonAlpha
|
||||||
timeWsOffsetColon
|
timeWsOffsetColon
|
||||||
timeWsYear // 15
|
timeWsYear // 15
|
||||||
|
timeWsYearOffset
|
||||||
timeOffset
|
timeOffset
|
||||||
timeOffsetColon
|
timeOffsetColon
|
||||||
timeAlpha
|
timeAlpha
|
||||||
timePeriod
|
timePeriod
|
||||||
timePeriodOffset // 20
|
timePeriodOffset
|
||||||
timePeriodOffsetColon
|
timePeriodOffsetColon
|
||||||
timePeriodOffsetColonWs
|
timePeriodOffsetColonWs
|
||||||
timePeriodWs
|
timePeriodWs
|
||||||
timePeriodWsAlpha
|
timePeriodWsAlpha
|
||||||
timePeriodWsOffset // 25
|
timePeriodWsOffset
|
||||||
timePeriodWsOffsetWs
|
timePeriodWsOffsetWs
|
||||||
timePeriodWsOffsetWsAlpha
|
timePeriodWsOffsetWsAlpha
|
||||||
timePeriodWsOffsetColon
|
timePeriodWsOffsetColon
|
||||||
@ -547,6 +548,7 @@ iterRunes:
|
|||||||
// Mon Jan _2 15:04:05 2006
|
// Mon Jan _2 15:04:05 2006
|
||||||
// Mon Jan _2 15:04:05 MST 2006
|
// Mon Jan _2 15:04:05 MST 2006
|
||||||
// Mon Jan 02 15:04:05 -0700 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
|
// Mon Aug 10 15:44:11 UTC+0100 2015
|
||||||
// Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time)
|
// Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time)
|
||||||
// dateAlphaWSDigit
|
// dateAlphaWSDigit
|
||||||
@ -636,6 +638,7 @@ iterRunes:
|
|||||||
// Mon Jan _2 15:04:05 2006
|
// Mon Jan _2 15:04:05 2006
|
||||||
// Mon Jan _2 15:04:05 MST 2006
|
// Mon Jan _2 15:04:05 MST 2006
|
||||||
// Mon Jan 02 15:04:05 -0700 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)
|
// Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time)
|
||||||
// Mon Aug 10 15:44:11 UTC+0100 2015
|
// Mon Aug 10 15:44:11 UTC+0100 2015
|
||||||
// dateAlphaWsDigit
|
// dateAlphaWsDigit
|
||||||
@ -708,6 +711,7 @@ iterRunes:
|
|||||||
case dateAlphaWsAlpha:
|
case dateAlphaWsAlpha:
|
||||||
// Mon Jan _2 15:04:05 2006
|
// Mon Jan _2 15:04:05 2006
|
||||||
// Mon Jan 02 15:04:05 -0700 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 Jan _2 15:04:05 MST 2006
|
||||||
// Mon Aug 10 15:44:11 UTC+0100 2015
|
// Mon Aug 10 15:44:11 UTC+0100 2015
|
||||||
// Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time)
|
// Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time)
|
||||||
@ -1075,6 +1079,8 @@ iterRunes:
|
|||||||
// 00:12:00 +00:00 UTC
|
// 00:12:00 +00:00 UTC
|
||||||
// timeWsYear
|
// timeWsYear
|
||||||
// 00:12:00 2008
|
// 00:12:00 2008
|
||||||
|
// timeWsYearOffset
|
||||||
|
// 00:12:00 2008 +0800
|
||||||
// timeZ
|
// timeZ
|
||||||
// 15:04:05.99Z
|
// 15:04:05.99Z
|
||||||
switch r {
|
switch r {
|
||||||
@ -1100,6 +1106,17 @@ iterRunes:
|
|||||||
p.yeari = i
|
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:
|
case timeWsAlpha:
|
||||||
// 06:20:00 UTC
|
// 06:20:00 UTC
|
||||||
// 06:20:00 UTC-05
|
// 06:20:00 UTC-05
|
||||||
@ -1448,6 +1465,8 @@ iterRunes:
|
|||||||
p.set(p.offseti, "-0700")
|
p.set(p.offseti, "-0700")
|
||||||
case timeWsOffset:
|
case timeWsOffset:
|
||||||
p.set(p.offseti, "-0700")
|
p.set(p.offseti, "-0700")
|
||||||
|
case timeWsYearOffset:
|
||||||
|
p.set(p.offseti, "-0700")
|
||||||
case timeWsOffsetWs:
|
case timeWsOffsetWs:
|
||||||
// 17:57:51 -0700 2009
|
// 17:57:51 -0700 2009
|
||||||
// 00:12:00 +0000 UTC
|
// 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: "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: "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"},
|
{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) {
|
func TestParse(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user