diff --git a/parseany.go b/parseany.go index b8559b2..b7f0a3c 100644 --- a/parseany.go +++ b/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 diff --git a/parseany_test.go b/parseany_test.go index 711f16c..8ce58d9 100644 --- a/parseany_test.go +++ b/parseany_test.go @@ -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) {