From 293071ed832800fbda498b80146a5b035c8cb5bb Mon Sep 17 00:00:00 2001 From: Aaron Raddon Date: Wed, 30 Sep 2020 12:17:37 -0700 Subject: [PATCH] Code cleanup, remove un-used code after #103 --- parseany.go | 40 ---------------------------------------- parseany_test.go | 9 +++++---- 2 files changed, 5 insertions(+), 44 deletions(-) diff --git a/parseany.go b/parseany.go index 3ccd072..95fc011 100644 --- a/parseany.go +++ b/parseany.go @@ -84,7 +84,6 @@ const ( dateAlphaWsMore dateAlphaWsAtTime dateAlphaWsAlpha - dateAlphaWsAlphaYearmaybe dateAlphaPeriodWsDigit dateWeekdayComma dateWeekdayAbbrevComma @@ -754,42 +753,6 @@ iterRunes: break iterRunes } - case dateAlphaWsAlpha: - // Mon Jan _2 15:04:05 2006 - // Mon Jan 02 15:04:05 -0700 2006 - // 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) - if r == ' ' { - if p.dayi > 0 { - p.daylen = i - p.dayi - p.setDay() - p.yeari = i + 1 - p.stateDate = dateAlphaWsAlphaYearmaybe - p.stateTime = timeStart - } - } else if unicode.IsDigit(r) { - if p.dayi == 0 { - p.dayi = i - } - } - - case dateAlphaWsAlphaYearmaybe: - // x - // Mon Jan _2 15:04:05 2006 - // Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time) - if r == ':' { - i = i - 3 - p.stateDate = dateAlphaWsAlpha - p.yeari = 0 - break iterRunes - } else if r == ' ' { - // must be year format, not 15:04 - p.yearlen = i - p.yeari - p.setYear() - break iterRunes - } - case dateAlphaWsMonth: // April 8, 2009 // April 8 2009 @@ -1694,9 +1657,6 @@ iterRunes: case dateAlphaWsDigitYearmaybe: return p, nil - case dateAlphaWsAlphaYearmaybe: - return p, nil - case dateDigitSlash: // 3/1/2014 // 10/13/2014 diff --git a/parseany_test.go b/parseany_test.go index 66bb14f..3b37bf9 100644 --- a/parseany_test.go +++ b/parseany_test.go @@ -11,8 +11,8 @@ import ( func TestOne(t *testing.T) { time.Local = time.UTC var ts time.Time - ts = MustParse("2018.09.30") - assert.Equal(t, "2018-09-30 00:00:00 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC))) + ts = MustParse("Mon 30 Sep 2018 09:09:09 PM UTC") + assert.Equal(t, "2018-09-30 21:09:09 +0000 UTC", fmt.Sprintf("%v", ts.In(time.UTC))) } type dateTest struct { @@ -42,10 +42,11 @@ var testInputs = []dateTest{ {in: "7 September 1970", out: "1970-09-07 00:00:00 +0000 UTC"}, // ANSIC = "Mon Jan _2 15:04:05 2006" {in: "Mon Jan 2 15:04:05 2006", out: "2006-01-02 15:04:05 +0000 UTC"}, - // ANSIC_GLIBC = "Mon 02 Jan 2006 03:04:05 PM UTC" - {in: "Mon 02 Jan 2006 03:04:05 PM UTC", out: "2006-01-02 15:04:05 +0000 UTC"}, {in: "Thu May 8 17:57:51 2009", out: "2009-05-08 17:57:51 +0000 UTC"}, {in: "Thu May 8 17:57:51 2009", out: "2009-05-08 17:57:51 +0000 UTC"}, + // ANSIC_GLIBC = "Mon 02 Jan 2006 03:04:05 PM UTC" + {in: "Mon 02 Jan 2006 03:04:05 PM UTC", out: "2006-01-02 15:04:05 +0000 UTC"}, + {in: "Mon 30 Sep 2018 09:09:09 PM UTC", out: "2018-09-30 21:09:09 +0000 UTC"}, // RubyDate = "Mon Jan 02 15:04:05 -0700 2006" {in: "Mon Jan 02 15:04:05 -0700 2006", out: "2006-01-02 22:04:05 +0000 UTC"}, {in: "Thu May 08 11:57:51 -0700 2009", out: "2009-05-08 18:57:51 +0000 UTC"},