The only required one.

This commit is contained in:
Arran Ubels 2023-02-15 16:31:37 +11:00
parent 3a32cbb3d2
commit b1fd89e43f
No known key found for this signature in database
GPG Key ID: 135EDC7B21D17F48

View File

@ -881,9 +881,6 @@ iterRunes:
p.setDay() p.setDay()
p.stateDate = dateAlphaWsDigitMore p.stateDate = dateAlphaWsDigitMore
} else if r == ' ' { } else if r == ' ' {
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.daylen = i - p.dayi p.daylen = i - p.dayi
p.setDay() p.setDay()
p.yeari = i + 1 p.yeari = i + 1
@ -907,9 +904,6 @@ iterRunes:
p.yeari = 0 p.yeari = 0
break iterRunes break iterRunes
} else if r == ' ' { } else if r == ' ' {
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
// must be year format, not 15:04 // must be year format, not 15:04
p.yearlen = i - p.yeari p.yearlen = i - p.yeari
p.setYear() p.setYear()
@ -923,9 +917,6 @@ iterRunes:
// oct 1, 1970 // oct 1, 1970
// oct 7, '70 // oct 7, '70
if r == ' ' { if r == ' ' {
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.yeari = i + 1 p.yeari = i + 1
p.stateDate = dateAlphaWsDigitMoreWs p.stateDate = dateAlphaWsDigitMoreWs
} }
@ -939,9 +930,6 @@ iterRunes:
case '\'': case '\'':
p.yeari = i + 1 p.yeari = i + 1
case ' ': case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
fallthrough fallthrough
case ',': case ',':
// x // x
@ -960,9 +948,6 @@ iterRunes:
// April 8 2009 // April 8 2009
switch r { switch r {
case ' ': case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
fallthrough fallthrough
case ',': case ',':
// x // x
@ -996,9 +981,6 @@ iterRunes:
i++ i++
break iterRunes break iterRunes
case ' ': case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.yearlen = i - p.yeari p.yearlen = i - p.yeari
p.setYear() p.setYear()
p.stateTime = timeStart p.stateTime = timeStart
@ -1053,9 +1035,6 @@ iterRunes:
} }
case r == ' ': case r == ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
// x // x
// January 02 2006, 15:04:05 // January 02 2006, 15:04:05
p.daylen = i - p.dayi p.daylen = i - p.dayi
@ -1079,9 +1058,6 @@ iterRunes:
// oct. 7, '70 // oct. 7, '70
switch { switch {
case r == ' ': case r == ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
// continue // continue
case unicode.IsDigit(r): case unicode.IsDigit(r):
p.stateDate = dateAlphaWsDigit p.stateDate = dateAlphaWsDigit
@ -1099,9 +1075,6 @@ iterRunes:
} }
switch r { switch r {
case ' ': case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
fallthrough fallthrough
case '-': case '-':
if p.moi == 0 { if p.moi == 0 {
@ -1258,9 +1231,6 @@ iterRunes:
// x // x
// September 17, 2012 at 5:00pm UTC-05 // September 17, 2012 at 5:00pm UTC-05
i++ // skip ' i++ // skip '
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.houri = 0 // reset hour p.houri = 0 // reset hour
} }
} else { } else {
@ -1285,9 +1255,6 @@ iterRunes:
p.set(i, "PM") p.set(i, "PM")
} }
case ' ': case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.coalesceTime(i) p.coalesceTime(i)
p.stateTime = timeWs p.stateTime = timeWs
case ':': case ':':
@ -1385,9 +1352,6 @@ iterRunes:
p.stateTime = timeWsAlphaZoneOffset p.stateTime = timeWsAlphaZoneOffset
p.offseti = i p.offseti = i
case ' ': case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
// 17:57:51 MST 2009 // 17:57:51 MST 2009
// 17:57:51 MST // 17:57:51 MST
p.tzlen = i - p.tzi p.tzlen = i - p.tzi
@ -1412,9 +1376,6 @@ iterRunes:
// 15:44:11 UTC+0100 2015 // 15:44:11 UTC+0100 2015
switch r { switch r {
case ' ': case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.set(p.offseti, "-0700") p.set(p.offseti, "-0700")
if p.yeari == 0 { if p.yeari == 0 {
p.yeari = i + 1 p.yeari = i + 1
@ -1477,9 +1438,6 @@ iterRunes:
case ':': case ':':
p.stateTime = timeWsOffsetColon p.stateTime = timeWsOffsetColon
case ' ': case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.set(p.offseti, "-0700") p.set(p.offseti, "-0700")
p.yeari = i + 1 p.yeari = i + 1
p.stateTime = timeWsOffsetWs p.stateTime = timeWsOffsetWs
@ -1560,9 +1518,6 @@ iterRunes:
// 06:20:00.000 UTC // 06:20:00.000 UTC
switch r { switch r {
case ' ': case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.mslen = i - p.msi p.mslen = i - p.msi
p.stateTime = timePeriodWs p.stateTime = timePeriodWs
case '+', '-': case '+', '-':
@ -1593,9 +1548,6 @@ iterRunes:
// 13:31:51.999 -07:00 MST // 13:31:51.999 -07:00 MST
switch r { switch r {
case ' ': case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.set(p.offseti, "-07:00") p.set(p.offseti, "-07:00")
p.stateTime = timePeriodOffsetColonWs p.stateTime = timePeriodOffsetColonWs
p.tzi = i + 1 p.tzi = i + 1
@ -1649,9 +1601,6 @@ iterRunes:
case ':': case ':':
p.stateTime = timePeriodWsOffsetColon p.stateTime = timePeriodWsOffsetColon
case ' ': case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.set(p.offseti, "-0700") p.set(p.offseti, "-0700")
case '+', '-': case '+', '-':
// This really doesn't seem valid, but for some reason when round-tripping a go date // This really doesn't seem valid, but for some reason when round-tripping a go date
@ -1681,9 +1630,6 @@ iterRunes:
// 13:31:51.999 -07:00 MST // 13:31:51.999 -07:00 MST
switch r { switch r {
case ' ': case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.set(p.offseti, "-07:00") p.set(p.offseti, "-07:00")
default: default:
if unicode.IsLetter(r) { if unicode.IsLetter(r) {