mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 11:51:54 +08:00
New date format September 17, 2012... closes #49
This commit is contained in:
parent
a769f5a7a1
commit
cc9d69bbea
@ -75,6 +75,7 @@ var examples = []string{
|
|||||||
"Thu, 4 Jan 2018 17:53:36 +0000",
|
"Thu, 4 Jan 2018 17:53:36 +0000",
|
||||||
"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)",
|
||||||
|
"September 17, 2012 at 10:09am PST-08",
|
||||||
"12 Feb 2006, 19:17",
|
"12 Feb 2006, 19:17",
|
||||||
"12 Feb 2006 19:17",
|
"12 Feb 2006 19:17",
|
||||||
"7 oct 70",
|
"7 oct 70",
|
||||||
@ -193,6 +194,7 @@ func main() {
|
|||||||
| Thu, 4 Jan 2018 17:53:36 +0000 | 2018-01-04 17:53:36 +0000 UTC |
|
| Thu, 4 Jan 2018 17:53:36 +0000 | 2018-01-04 17:53:36 +0000 UTC |
|
||||||
| Mon Aug 10 15:44:11 UTC+0100 2015 | 2015-08-10 15:44:11 +0000 UTC |
|
| Mon Aug 10 15:44:11 UTC+0100 2015 | 2015-08-10 15:44:11 +0000 UTC |
|
||||||
| Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time) | 2015-07-03 18:04:07 +0100 GMT |
|
| Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time) | 2015-07-03 18:04:07 +0100 GMT |
|
||||||
|
| September 17, 2012 at 10:09am PST-08 | 2012-09-17 10:09:00 -0800 PST |
|
||||||
| 12 Feb 2006, 19:17 | 2006-02-12 19:17:00 +0000 UTC |
|
| 12 Feb 2006, 19:17 | 2006-02-12 19:17:00 +0000 UTC |
|
||||||
| 12 Feb 2006 19:17 | 2006-02-12 19:17:00 +0000 UTC |
|
| 12 Feb 2006 19:17 | 2006-02-12 19:17:00 +0000 UTC |
|
||||||
| 7 oct 70 | 1970-10-07 00:00:00 +0000 UTC |
|
| 7 oct 70 | 1970-10-07 00:00:00 +0000 UTC |
|
||||||
|
@ -23,6 +23,7 @@ var examples = []string{
|
|||||||
"Thu, 4 Jan 2018 17:53:36 +0000",
|
"Thu, 4 Jan 2018 17:53:36 +0000",
|
||||||
"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)",
|
||||||
|
"September 17, 2012 at 10:09am PST-08",
|
||||||
"12 Feb 2006, 19:17",
|
"12 Feb 2006, 19:17",
|
||||||
"12 Feb 2006 19:17",
|
"12 Feb 2006 19:17",
|
||||||
"7 oct 70",
|
"7 oct 70",
|
||||||
@ -141,6 +142,7 @@ func main() {
|
|||||||
| Thu, 4 Jan 2018 17:53:36 +0000 | 2018-01-04 17:53:36 +0000 UTC |
|
| Thu, 4 Jan 2018 17:53:36 +0000 | 2018-01-04 17:53:36 +0000 UTC |
|
||||||
| Mon Aug 10 15:44:11 UTC+0100 2015 | 2015-08-10 15:44:11 +0000 UTC |
|
| Mon Aug 10 15:44:11 UTC+0100 2015 | 2015-08-10 15:44:11 +0000 UTC |
|
||||||
| Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time) | 2015-07-03 18:04:07 +0100 GMT |
|
| Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time) | 2015-07-03 18:04:07 +0100 GMT |
|
||||||
|
| September 17, 2012 at 10:09am PST-08 | 2012-09-17 10:09:00 -0800 PST |
|
||||||
| 12 Feb 2006, 19:17 | 2006-02-12 19:17:00 +0000 UTC |
|
| 12 Feb 2006, 19:17 | 2006-02-12 19:17:00 +0000 UTC |
|
||||||
| 12 Feb 2006 19:17 | 2006-02-12 19:17:00 +0000 UTC |
|
| 12 Feb 2006 19:17 | 2006-02-12 19:17:00 +0000 UTC |
|
||||||
| 7 oct 70 | 1970-10-07 00:00:00 +0000 UTC |
|
| 7 oct 70 | 1970-10-07 00:00:00 +0000 UTC |
|
||||||
|
@ -586,6 +586,13 @@ iterRunes:
|
|||||||
|
|
||||||
switch {
|
switch {
|
||||||
case r == ' ':
|
case r == ' ':
|
||||||
|
if i > 4 {
|
||||||
|
// September 17, 2012 at 5:00pm UTC-05
|
||||||
|
// This one doesn't follow standard parse methodologies. the "January"
|
||||||
|
// is difficult to use the format string replace method because of its variable-length (march, june)
|
||||||
|
// so we just use this format here. If we see more similar to this we will do something else.
|
||||||
|
return parse("January 02, 2006 at 3:04pm MST-07", datestr, loc)
|
||||||
|
}
|
||||||
p.stateDate = dateAlphaWs
|
p.stateDate = dateAlphaWs
|
||||||
case r == ',':
|
case r == ',':
|
||||||
// p.moi = 0
|
// p.moi = 0
|
||||||
|
@ -160,6 +160,9 @@ var testInputs = []dateTest{
|
|||||||
{in: "Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time)", out: "2015-07-03 17:04:07 +0000 UTC"},
|
{in: "Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time)", out: "2015-07-03 17:04:07 +0000 UTC"},
|
||||||
{in: "Fri Jul 3 2015 06:04:07 GMT+0100 (GMT Daylight Time)", out: "2015-07-03 05:04:07 +0000 UTC"},
|
{in: "Fri Jul 3 2015 06:04:07 GMT+0100 (GMT Daylight Time)", out: "2015-07-03 05:04:07 +0000 UTC"},
|
||||||
{in: "Fri Jul 3 2015 06:04:07 PST-0700 (Pacific Daylight Time)", out: "2015-07-03 13:04:07 +0000 UTC"},
|
{in: "Fri Jul 3 2015 06:04:07 PST-0700 (Pacific Daylight Time)", out: "2015-07-03 13:04:07 +0000 UTC"},
|
||||||
|
// Month dd, yyyy
|
||||||
|
{in: "September 17, 2012 at 5:00pm UTC-05", out: "2012-09-17 17:00:00 +0000 UTC"},
|
||||||
|
{in: "September 17, 2012 at 10:09am PST-08", out: "2012-09-17 18:09:00 +0000 UTC"},
|
||||||
// ?
|
// ?
|
||||||
{in: "Fri, 03 Jul 2015 08:08:08 MST", out: "2015-07-03 08:08:08 +0000 UTC"},
|
{in: "Fri, 03 Jul 2015 08:08:08 MST", out: "2015-07-03 08:08:08 +0000 UTC"},
|
||||||
{in: "Fri, 03 Jul 2015 08:08:08 PST", out: "2015-07-03 15:08:08 +0000 UTC", loc: "America/Los_Angeles"},
|
{in: "Fri, 03 Jul 2015 08:08:08 PST", out: "2015-07-03 15:08:08 +0000 UTC", loc: "America/Los_Angeles"},
|
||||||
|
Loading…
Reference in New Issue
Block a user