File tree Expand file tree Collapse file tree 2 files changed +10
-14
lines changed Expand file tree Collapse file tree 2 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -1193,8 +1193,10 @@ iterRunes:
11931193 }
11941194 switch r {
11951195 case ',' :
1196- // hm, lets just swap out comma for period. for some reason go
1197- // won't parse it.
1196+ // swap out comma for period.
1197+ // Newer versions of Go support comma as a separator, but colon is still unsupported
1198+ // https://go-review.googlesource.com/c/go/+/300996
1199+ //
11981200 // 2014-05-11 08:20:13,787
11991201 ds := []byte (p .datestr )
12001202 ds [i ] = '.'
@@ -1270,18 +1272,11 @@ iterRunes:
12701272 p .seci = i + 1
12711273 p .minlen = i - p .mini
12721274 } else if p .seci > 0 {
1273- // 18:31:59:257 ms uses colon, wtf
1274- p .seclen = i - p .seci
1275- p .set (p .seci , "05" )
1276- p .msi = i + 1
1277-
1278- // gross, gross, gross. manipulating the datestr is horrible.
1279- // https://github.com/araddon/dateparse/issues/117
1280- // Could not get the parsing to work using golang time.Parse() without
1281- // replacing that colon with period.
1282- p .set (i , "." )
1283- datestr = datestr [0 :i ] + "." + datestr [i + 1 :]
1284- p .datestr = datestr
1275+ // 18:31:59:257 ms is separated with a colon
1276+ // swap out the colon for a period and re-parse
1277+ ds := []byte (p .datestr )
1278+ ds [i ] = '.'
1279+ return parseTime (string (ds ), loc , opts ... )
12851280 }
12861281 }
12871282 case timeOffset :
Original file line number Diff line number Diff line change @@ -384,6 +384,7 @@ var testInputs = []dateTest{
384384 {in : "2016-06-21T19:55+0130" , out : "2016-06-21 18:25:00 +0000 UTC" },
385385 // yyyy-mm-ddThh:mm:ss:000+0000 - weird format with additional colon in front of milliseconds
386386 {in : "2012-08-17T18:31:59:257+0100" , out : "2012-08-17 17:31:59.257 +0000 UTC" }, // https://github.com/araddon/dateparse/issues/117
387+ {in : "2012-08-17T18:31:59:257" , out : "2012-08-17 18:31:59.257 +0000 UTC" }, // https://github.com/araddon/dateparse/issues/137
387388
388389 // yyyy-mm-ddThh:mm:ssZ
389390 {in : "2009-08-12T22:15Z" , out : "2009-08-12 22:15:00 +0000 UTC" },
You can’t perform that action at this time.
0 commit comments