-
Notifications
You must be signed in to change notification settings - Fork 26
Fixes Negative numbers for @ not being recognized #43
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
Conversation
9db328c
to
d3383c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely! I have some minor comments, but it's looking pretty good!
9071053
to
cbfc1cf
Compare
@tertsdiepraam adjusted the code. |
cbfc1cf
to
57f871e
Compare
src/parse_timestamp.rs
Outdated
use nom::sequence::tuple; | ||
use nom::{self, IResult}; | ||
|
||
pub(crate) fn parse_timestamp(s: &str) -> Option<i64> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we return:
Result<i64, ParseTimestampError>
like we return ParseDateTimeError elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/parse_timestamp.rs
Outdated
let res: IResult<&str, (char, &str)> = all_consuming(preceded( | ||
char('@'), | ||
tuple(( | ||
// Note: gnu date allows multiple + and - and only considers the last one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add that we are doing the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -0,0 +1,67 @@ | |||
use nom::branch::alt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add the license header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/lib.rs
Outdated
return Ok(dt); | ||
} | ||
if let Some(timestamp) = parse_timestamp(s.as_ref()) { | ||
let timestamp_date = NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens in case of error ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
This commit resolves uutils#40. Adds new file and functions parse_timestamp. Adds tests for handling negative numbers.
57f871e
to
b150932
Compare
@sylvestre updated, let me know if you like to resolve the comments, or i should. I am not sure how you handle it. |
@tertsdiepraam @sylvestre just checking on the status. I think someone needs to review it. |
This commit resolves #40.
Adds new file and functions parse_timestamp.
Adds tests for handling negative numbers.
@tertsdiepraam @sylvestre