Conversation
|
@tertsdiepraam I squashed your commits into a single commit, I hope you don't mind |
ff67b9e to
85d7574
Compare
|
Looks cool! A few initial comments to send you in the right direction. One of the reasons for this rewrite is that chrono wasn't cutting it for adding all the items together. Instead we should add all the items together ourselves to really match GNU. It'll require a lot of experimentation, but it'll make the compatibility much better. I think most of the corner cases were around the ends of months. I believe GNU had some overflow behaviour there that chrono didn't. So I recommend first creating a custom datetime struct to manipulate and then mapping that to chrono. Squashing the commit is absolutely fine by the way. Thanks for continuing this! |
5516eed to
9388e45
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #86 +/- ##
===========================================
- Coverage 85.93% 62.66% -23.28%
===========================================
Files 6 9 +3
Lines 853 1248 +395
Branches 188 409 +221
===========================================
+ Hits 733 782 +49
- Misses 117 134 +17
- Partials 3 332 +329
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e858dfd to
417fde9
Compare
Hi Terts, I introduced a function to create dates from naive dates instead of using About the month behavior, if I understood correctly GNU gets the number of the days in the current month and adds it to the date, I implemented this behavior added your test and one more. |
417fde9 to
68498fa
Compare
|
@tertsdiepraam I was looking into the fuzzy testing. I added the code so it generates fuzzy dates with some sanity and caught some problems, I will look into them next. |
fuzz/fuzz_targets/parse_datetime.rs
Outdated
| // Testing GNU compatibility by calling date and | ||
| // comparing the inputs | ||
|
|
||
| // let fmt = "%Y-%m-%d %H:%M:%S"; | ||
| // let mut output: process::Output = std::process::Command::new("date") | ||
| // .arg("-d") | ||
| // .arg(s) | ||
| // .arg(format!("+{fmt}")) | ||
| // .output() | ||
| // .expect("date command failed"); | ||
| // io::stdout().write_all(&output.stdout).unwrap(); | ||
| // io::stdout().write_all(&output.stderr).unwrap(); | ||
| // output.stdout.pop(); // remove trailing \n | ||
| // assert_eq!( | ||
| // String::from_utf8(output.stdout).unwrap(), | ||
| // d.format(fmt).to_string() | ||
| // ); |
There was a problem hiding this comment.
I was testing something like this to determine its compatibility with GNU. The test run GNU date in and compare the outputs
There was a problem hiding this comment.
We could definitely do that with fuzzing! We should still rely on regular tests as well though.
2389d91 to
025808c
Compare
src/lib.rs
Outdated
| #[test] | ||
| fn chrono_date() { | ||
| const FMT: &str = "%Y-%m-%d %H:%M:%S"; | ||
| let input = "262144-03-10 00:00:00"; | ||
|
|
||
| // chrono rejects this specific date | ||
| assert!(NaiveDate::from_ymd_opt(262144, 3, 10).is_none()); | ||
| assert!(chrono::DateTime::parse_from_str(input, FMT).is_err()); | ||
| // the parsing works, but hydration fails | ||
| assert!(items::parse(&mut input.to_string().as_str()).is_ok()); | ||
| assert!(parse_datetime(input).is_err()); | ||
| // GNU date works | ||
| assert_eq!(make_gnu_date(input, FMT), input); | ||
| } |
There was a problem hiding this comment.
@tertsdiepraam I found a case where GNU accepts the date, we can parse it and chrono rejects it, more precisely chrono::NaiveDate::from_ymd_opt returns None for this date. I don't know what direction to take from there, chrono keeps getting in the way 😅 ideas? Maybe having a gnu-compatible datetime layer, but that will be a lot of work
539a63f to
307c159
Compare
|
sorry but some tests are failing: and needs some rebasing |
I will rebase it But right now I have a problem with Chrono, I'm looking into alternatives like https://time-rs.github.io/book/how-to/create-dates.html |
|
Hello, I updated the PR, some key notes:
Let me know what you think, if this is too bad, or if it is okay for now. I guess that to achieve 100% BTW I was playing with GNU date and I found this behavior Here |
Cargo.toml
Outdated
| [features] | ||
| debug = ["winnow/debug"] | ||
|
|
||
| [[bin]] |
There was a problem hiding this comment.
should be done in a different PR, no?
There was a problem hiding this comment.
Yes! I added to compare some dates with GNU, I'm removing this
| [dependencies.parse_datetime] | ||
| path = "../" | ||
|
|
||
| [features] |
There was a problem hiding this comment.
To see the trace output I need build it with winnow/debug/ feature. I tried cargo fuzz --features winnow/debug but it didn't worked. So I added this debug feature that depends on winnow/debug and I can enable it instead
|
Nice to see OSS contributions working fine @dhilst |


Continuing the rewrite started by @tertsdiepraam #61
lib.rskeep the same signaturelib.rstoo all they are passing@\d+formatMMDDhhmm