Skip to content

Commit

Permalink
Added extra test cases and fixing typos
Browse files Browse the repository at this point in the history
  • Loading branch information
iTanken committed Apr 2, 2024
1 parent bfdab07 commit 7758036
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 50 deletions.
20 changes: 11 additions & 9 deletions parseany.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ const (
dateAlphaWsMonthMore
dateAlphaWsMonthSuffix
dateAlphaWsMore
dateAlphaWsAtTime
//dateAlphaWsAtTime
dateAlphaWsAlpha
dateAlphaWsAlphaYearmaybe // 35
//dateAlphaWsAlphaYearmaybe // 35
dateAlphaPeriodWsDigit
dateWeekdayComma
dateWeekdayAbbrevComma
Expand Down Expand Up @@ -118,15 +118,15 @@ const (
timeWsYear // 15
timeOffset
timeOffsetColon
timeAlpha
//timeAlpha
timePeriod
timePeriodOffset // 20
timePeriodOffsetColon
timePeriodOffsetColonWs
timePeriodWs
timePeriodWsAlpha
timePeriodWsOffset // 25
timePeriodWsOffsetWs
//timePeriodWsOffsetWs
timePeriodWsOffsetWsAlpha
timePeriodWsOffsetColon
timePeriodWsOffsetColonAlpha
Expand Down Expand Up @@ -1370,7 +1370,7 @@ iterRunes:
p.minlen = i - p.mini
} else if p.seci > 0 {
// 18:31:59:257 ms is separated with a colon
// swap out the colon for a period and re-parse
// swap out the colon for a period and reparse
ds := []byte(p.datestr)
ds[i] = '.'
return parseTime(string(ds), loc, opts...)
Expand Down Expand Up @@ -1559,7 +1559,7 @@ iterRunes:
}
case '+', '-', '(':
// This really doesn't seem valid, but for some reason when round-tripping a go date
// their is an extra +03 printed out. seems like go bug to me, but, parsing anyway.
// there is an extra +03 printed out. seems like go bug to me, but, parsing anyway.
// 00:00:00 +0300 +03
// 00:00:00 +0300 +0300
p.extra = i - 1
Expand Down Expand Up @@ -1706,7 +1706,7 @@ iterRunes:
p.set(p.offseti, "-0700")
case '+', '-':
// This really doesn't seem valid, but for some reason when round-tripping a go date
// their is an extra +03 printed out. seems like go bug to me, but, parsing anyway.
// there is an extra +03 printed out. seems like go bug to me, but, parsing anyway.
// 00:00:00.000 +0300 +03
// 00:00:00.000 +0300 +0300
p.extra = i - 1
Expand Down Expand Up @@ -1752,7 +1752,7 @@ iterRunes:
if unicode.IsDigit(r) {
p.stateTime = timeZDigit
}

default:
}
}

Expand Down Expand Up @@ -1839,13 +1839,14 @@ iterRunes:
}
case timePeriodWsOffset:
p.set(p.offseti, "-0700")
default:
}
p.coalesceTime(i)
}

switch p.stateDate {
case dateDigit:
// unixy timestamps ish
// unix timestamps ish
// example ct type
// 1499979655583057426 19 nanoseconds
// 1499979795437000 16 micro-seconds
Expand Down Expand Up @@ -2098,6 +2099,7 @@ iterRunes:

case dateYearWsMonthWs:
return p, nil
default:
}

return nil, unknownErr(datestr)
Expand Down
Loading

0 comments on commit 7758036

Please sign in to comment.