Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comprehensive validation πŸ”Ž, 30+ fixes integrated/added πŸ”¨πŸ›, optimized performance πŸš€ #159

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
335c1f9
added some actions
arran4 Feb 15, 2023
26d95ba
My issue
arran4 Feb 15, 2023
5335e6f
Error return value is not checked (errcheck)
arran4 Feb 15, 2023
14cb70e
field `offsetlen` is unused (unused)
arran4 Feb 15, 2023
2fb4c46
S1021: should merge variable declaration with assignment on next line…
arran4 Feb 15, 2023
5143d47
S1023: redundant break statement (gosimple)
arran4 Feb 15, 2023
57a1767
SA4006: this value of `err` is never used (staticcheck)
arran4 Feb 15, 2023
ad0ab84
Lint action out of date.
arran4 Feb 15, 2023
a8e238d
Go mod tidy
arran4 Feb 15, 2023
e654ac7
Bug fixes.
arran4 Feb 15, 2023
cefe5b3
More typo changes
arran4 Feb 15, 2023
4345a38
Another error
arran4 Feb 15, 2023
515cd81
S1023: redundant break statement (gosimple)
arran4 Feb 15, 2023
eabb56b
Text should be lowercase
arran4 Feb 15, 2023
c5b562a
Added go releaser
arran4 Feb 15, 2023
094aad3
Commented code
arran4 Feb 15, 2023
53a8cbd
Unnecessary bracket
arran4 Feb 15, 2023
544b542
Test improvements.. I think
arran4 Feb 15, 2023
c5a1edc
My addition last
arran4 Feb 15, 2023
268a690
So people don't have to check the string they can use the new errors.…
arran4 Feb 15, 2023
bf3a5b3
Skip white space - to delete strategically
arran4 Feb 15, 2023
3a32cbb
All of these did nothing
arran4 Feb 15, 2023
b1fd89e
The only required one.
arran4 Feb 15, 2023
19ef6a2
New failure - still white space
arran4 Feb 15, 2023
8b765a5
Skip white space
arran4 Feb 15, 2023
b0b5409
Unused code
arran4 Feb 15, 2023
01b692d
Another case.
arran4 Feb 15, 2023
465140d
Fix ineffective break statements
klondikedragon Dec 9, 2023
1b1e0b3
Add extensive format validation, bugfixes
klondikedragon Dec 12, 2023
3ebc8bc
Incorporate fix for dd.mm.yyyy format
klondikedragon Dec 12, 2023
c62ed15
Support PMDT and AMT time zones
klondikedragon Dec 13, 2023
49f9259
Add support for dd[th,nd,st,rd] Month yyyy
klondikedragon Dec 13, 2023
301ffee
Add support for mon/dd/yyyy (Oct/31/1970)
klondikedragon Dec 13, 2023
18938f1
Implement support for yyyy mon dd (2013 May 02)
klondikedragon Dec 13, 2023
fc278d3
Incorporate support for dd-mm-yyyy (digit month)
klondikedragon Dec 13, 2023
df9ae2e
Incorporate support for yyyymmddhhmmss.SSS
klondikedragon Dec 13, 2023
8f0059d
Add tests to verify ambiguous cases
klondikedragon Dec 13, 2023
2b3f700
Handle format "date time (MST)"
klondikedragon Dec 14, 2023
d05b099
Add better timezone explanation to README.md
klondikedragon Dec 14, 2023
14fb939
Fix parsing for format (time) UTC[+-]NNNN
klondikedragon Dec 15, 2023
23869f3
Add support for mm/dd/yyyy, hh:mm:ss
klondikedragon Dec 15, 2023
cc63421
Support times after yyyy.mm.dd dates
klondikedragon Dec 15, 2023
18ec8c6
Expand Chinese date format support
klondikedragon Dec 16, 2023
249dd73
Support git log format (Thu Apr 7 15:13:13 2005 -0700)
klondikedragon Dec 16, 2023
0c3943e
Support RabbitMQ log format (dd-mon-yyyy::hh:mm:ss)
klondikedragon Dec 16, 2023
0d2fd5e
Add broader benchmarks
klondikedragon Dec 16, 2023
f4307ef
Heavily optimize memory allocations
klondikedragon Dec 16, 2023
ed5310d
Optimize ambiguous date parsing
klondikedragon Dec 16, 2023
23f8fa1
Further optimize ambiguous parsing
klondikedragon Dec 16, 2023
d2e1443
Comprehensive date format validation
klondikedragon Dec 17, 2023
fbf07cc
Optimize memory for error case
klondikedragon Dec 17, 2023
a45d593
Optimize checks for day of week and full month
klondikedragon Dec 17, 2023
89df0f8
Comprehensive time validation
klondikedragon Dec 19, 2023
7a3c923
Fix mm.dd.yyyy (time) format
klondikedragon Dec 19, 2023
65e6e8d
Add support for dd-month-year format
klondikedragon Dec 19, 2023
4f7e854
Update example and README.md with new formats
klondikedragon Dec 19, 2023
4d76f59
Fix ambiguous mm/dd that start with weekday
klondikedragon Dec 19, 2023
5cb2793
Update benchmark results
klondikedragon Dec 19, 2023
9f7bdf7
Update go doc
klondikedragon Dec 20, 2023
fd21b1e
Allow weekday prefix for most date formats
klondikedragon Dec 24, 2023
c4de5d4
Unify/fix timezone offset/name states
klondikedragon Dec 30, 2023
d5b3c60
Cleanup handling of TZ name parsing
klondikedragon Dec 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
The only required one.
arran4 committed Feb 15, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit b1fd89e43f72b58e0aa987c45f818a8cf6b24bb6
56 changes: 1 addition & 55 deletions parseany.go
Original file line number Diff line number Diff line change
@@ -881,9 +881,6 @@ iterRunes:
p.setDay()
p.stateDate = dateAlphaWsDigitMore
} else if r == ' ' {
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.daylen = i - p.dayi
p.setDay()
p.yeari = i + 1
@@ -907,9 +904,6 @@ iterRunes:
p.yeari = 0
break iterRunes
} else if r == ' ' {
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
// must be year format, not 15:04
p.yearlen = i - p.yeari
p.setYear()
@@ -923,9 +917,6 @@ iterRunes:
// oct 1, 1970
// oct 7, '70
if r == ' ' {
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.yeari = i + 1
p.stateDate = dateAlphaWsDigitMoreWs
}
@@ -939,9 +930,6 @@ iterRunes:
case '\'':
p.yeari = i + 1
case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
fallthrough
case ',':
// x
@@ -960,9 +948,6 @@ iterRunes:
// April 8 2009
switch r {
case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
fallthrough
case ',':
// x
@@ -996,9 +981,6 @@ iterRunes:
i++
break iterRunes
case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.yearlen = i - p.yeari
p.setYear()
p.stateTime = timeStart
@@ -1053,9 +1035,6 @@ iterRunes:
}

case r == ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
// x
// January 02 2006, 15:04:05
p.daylen = i - p.dayi
@@ -1079,9 +1058,6 @@ iterRunes:
// oct. 7, '70
switch {
case r == ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
// continue
case unicode.IsDigit(r):
p.stateDate = dateAlphaWsDigit
@@ -1099,9 +1075,6 @@ iterRunes:
}
switch r {
case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
fallthrough
case '-':
if p.moi == 0 {
@@ -1257,10 +1230,7 @@ iterRunes:
if p.nextIs(i, ' ') {
// x
// September 17, 2012 at 5:00pm UTC-05
i++ // skip '
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
i++ // skip '
p.houri = 0 // reset hour
}
} else {
@@ -1285,9 +1255,6 @@ iterRunes:
p.set(i, "PM")
}
case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.coalesceTime(i)
p.stateTime = timeWs
case ':':
@@ -1385,9 +1352,6 @@ iterRunes:
p.stateTime = timeWsAlphaZoneOffset
p.offseti = i
case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
// 17:57:51 MST 2009
// 17:57:51 MST
p.tzlen = i - p.tzi
@@ -1412,9 +1376,6 @@ iterRunes:
// 15:44:11 UTC+0100 2015
switch r {
case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.set(p.offseti, "-0700")
if p.yeari == 0 {
p.yeari = i + 1
@@ -1477,9 +1438,6 @@ iterRunes:
case ':':
p.stateTime = timeWsOffsetColon
case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.set(p.offseti, "-0700")
p.yeari = i + 1
p.stateTime = timeWsOffsetWs
@@ -1560,9 +1518,6 @@ iterRunes:
// 06:20:00.000 UTC
switch r {
case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.mslen = i - p.msi
p.stateTime = timePeriodWs
case '+', '-':
@@ -1593,9 +1548,6 @@ iterRunes:
// 13:31:51.999 -07:00 MST
switch r {
case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.set(p.offseti, "-07:00")
p.stateTime = timePeriodOffsetColonWs
p.tzi = i + 1
@@ -1649,9 +1601,6 @@ iterRunes:
case ':':
p.stateTime = timePeriodWsOffsetColon
case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.set(p.offseti, "-0700")
case '+', '-':
// 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
switch r {
case ' ':
for i+1 < len(datestr) && datestr[i+1] == ' ' {
i++
}
p.set(p.offseti, "-07:00")
default:
if unicode.IsLetter(r) {