-
Notifications
You must be signed in to change notification settings - Fork 176
Comprehensive validation π, 30+ fixes integrated/added π¨π, optimized performance π #159
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
base: master
Are you sure you want to change the base?
Conversation
* Don't just assume we were given one of the valid formats. * Also consolidate the parsing states that occur after timePeriod. * Add subtests to make it easier to see what fails. * Additional tests for 4-char timezone names. * Fix araddon#117 * Fix araddon#150 * Fix araddon#157 * Fix araddon#145 * Fix araddon#108 * Fix araddon#137 * Fix araddon#130 * Fix araddon#123 * Fix araddon#109 * Fix araddon#98 * Addresses bug in araddon#100 (comment) Adds test cases to verify the following are already fixed: * araddon#94
Incorporates PR araddon#133 from https://github.com/mehanizm to fix araddon#129 Adds test cases to verify the following are already fixed: * araddon#105
Fully support the format where a TZ name is in parentheses after the time (and possibly after an offset). This fixes the broken case where a 4 character TZ name was in parentheses after a time.
|
great work @klondikedragon . How can i start using this? |
|
I'll go ahead and fork this package. I'm renaming the main branch as part of that. |
Various other cleanup: * Update README.md * Update github workflows * Add to copyright * Add .gitignore
Prepare v0.1.0 release
|
The fork is complete and published as The fork is available using @elliot40404 @arran4 @jmdacruz -- see what you think and how this updated package works! If this looks good and after incorporating feedback, I think I'll publish a v1.0.0 at some point soon. I'm also curious to get feedback on my log management project too, check out the site/discord if you're interested. Thanks! |
fixed lib import
(chore) upgrade deps
Support --prefer-day-first and --retry-ambiguous flags for example program. Also provide an example where parsing would fail without it.
Enhance dateparse example with flags related to ambiguous formats
Many devices send dates that do not conform to the RFCs... Also add support for the strange "TZ-0700" variant of the "UTC-0700" offset. Cover all the changes with new tests.
Support for RFC3164/RFC5424 syslog formats
|
What happened? |
|
@arran4 sorry... I was cleaning up old branches when releasing a new version of https://github.com/itlightning/dateparse (part of work to add automated config-free syslog parsing/ingestion to https://sparklogs.com/ ), and I forgot that deleting the old v0.2.1 of the github.com/itlightning/dateparse package is now available with support for additional syslog RFC3164/RFC5424 time formats (and their many variants). Dependencies were also updated. Use/development of the package continues to be active there and feedback welcome. |
This package is amazing and hugely popular, and has been the best package for automatic date parsing in go for years! β
Thanks @araddon for crafting this package with love over the years!!
I've been using this while developing a new cloud-based log aggregation/search/visualization product, and I've found that there are three major opportunities for improvement for my particular use case:
This PR addresses all 3 opportunities:
SimpleErrorMessagesoption was added (off by default) that greatly speeds up the case where a string does not match a known format -- with the option on, this case is now 4x faster and produces almost no allocations.In the process of going through the state machine comprehensively for validation, redundant code/states were merged, and support was added for certain edge cases (for example, some date formats did not support being followed by times).
The example and README.md were updated to incorporate all of the newly supported formats and edge cases. More details on how to properly interpret returned location information with respect to abbreviated timezones was added.
BREAKING -- the package now requires go >= 1.20 to support memory optimizations converting from
[]bytetostringin key places.A huge thanks to all who posted issues and contributed PRs -- while the PRs were unable to be merged directly because the validation changes were so major, the ideas of all these contributions and the associated test cases were incorporated. Here's credit for all of the issues fixes and contributions in this PR as well as a summary of additional fixes added:
2015-06-10 00:00:00 GMT+02:00Β #78 (support for GMT+offset, support additional whitespace in certain places, and other changes)"1.jpg"incorrectly parsed as valid - fixed by comprehensive validationThu Jan 28 2021 15:28:21 GMT+0000formatyyyy mon ddformat - adapt Add support for dates of the form "yyyy mmm dd" where mmm is alphaΒ #142 by @dferstayyyyymmddhhmmss.SSSformat - adapt support combined datetime format with subseconds (yyyyMMddhhmmss.SSS)Β #144 by @dferstay2017-04-03 22:32:14.322 CET)Sun, 07 Jun 2020 00:00:00 +0100format1 April 2022 23:59format (time after certain date formats)mm.dd.yyyy (time)- adapted fix problem with date format 02.01.2006Β #133 by @mehanizm (also fixes Better support for dot-format (e.g. 13.1.2009) with ambiguousMMDDΒ #91 and Request: Support for DD/MM/YYYYΒ #28)PMDTandAMTtime zones and validate that AM/PM indicators only appear at most oncedd[th,nd,st,rd] Month yyyyformat - adapt New date format 1st November 2020Β #128 by @krhubert(time) UTC[+-]NNNNmm/dd/yyyy, hh:mm:ssformat - adapt added comma format like04/2/2014, 03:00:37Β #156 by @BrianLeishmanyyyy.mm.dd (time)format - adapt Bug parsing 2014.02.13 00:00:00 ?Β #134 by @jmdacruz, and add cases expected to fail toTestParseErrorsunit testThu Apr 7 15:13:13 2005 -0700) - adapt commit 99d9682 from Add support for git date formatΒ #92 by @jiangxin (merge timeWsYearOffset case and add validation)dd-mon-yyyy::hh:mm:ss) - adapt rabbitmq log datetime supportΒ #122 by @bizy01mon/dd/yyyyformat, e.g.,Oct/31/1970dd-month-yearformatyyyy-mon-ddto allow times to follow it. Also allow full month name instead of just abbreviated.mm:dd:yyyyformatMonday January 4th, 2017)mm.dd.yyyy (time)formatmm/ddformats that start with a weekdayAlso adds tests to verify that the following stay fixed:
190910 11:51:49