-
Notifications
You must be signed in to change notification settings - Fork 26
Make parse_datetime::parse_datetime::from_str accept relative time #33
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
Make parse_datetime::parse_datetime::from_str accept relative time #33
Conversation
771b565
to
82ea54a
Compare
I think this is an opportunity to clean up the interface. There's no reason to expose multiple functions with overlapping functionality. The only public items should be:
The This would hide functions that we are currently using in coreutils, but those should be forced to change :) |
That makes sense. I think i can tackle that, but with those changes we
should probably also increase the version number. It might cause quite some
conflict for existing prs.
…On Mon, Aug 21, 2023 at 21:01 Terts Diepraam ***@***.***> wrote:
I think this is an opportunity to clean up the interface. There's no
reason to expose multiple functions with overlapping functionality. The
only public items should be:
- A parse_datetime *function* (module should be private and be renamed)
- A parse_datetime_at_date function
- ParseDateTimeError (renamed from ParseDurationError)
The parse_datetime module could be called datetime_format maybe (or some
other name).
This would hide functions that we are currently using in coreutils, but
those should be forced to change :)
—
Reply to this email directly, view it on GitHub
<#33 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABP4LZTFKHNL6UZSISZYKBDXWNEZTANCNFSM6AAAAAA3YHMPWE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Great! Thanks!
I agree, we'll bump the version number on the next release.
Indeed. It's a bit unfortunate, but the sooner we do this the better in my opinion. |
7773727
to
5e8dca9
Compare
@tertsdiepraam I have done some refactoring. When you have some time, can you take a look a look (its quite a big renaming / refactor, so i am sure there will be some revisions). Here is what i did:
|
5e8dca9
to
3a68715
Compare
We'll get to the version number once we actually publish. You can revert that for now. Also, |
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.
First little comment. I'll get to the rest once the CI passes. But looks promising!
@tertsdiepraam Sure, and thanks for the comments. I will mention you ones the pipeline is fixed. |
7b72550
to
a99af04
Compare
@tertsdiepraam the pipeline is passing now. |
needs to be rebased :) |
2ae1b40
to
ce6ea28
Compare
@sylvestre rebased |
Any updates/ feedback? |
It's only been a day. We're not that fast ;p I'll take a look soon! |
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.
Alright, sorry it took a while. These kinds of changes are always a bit hard to review, because it's hard to distinguish stuff being moved around with actual changes in the code. I might have accidentally commented on some things that aren't due to this change. If that's the case, just reply saying that it's irrelevant :)
@tertsdiepraam thanks for taking the time to review this. |
016cf2a
to
42def80
Compare
42def80
to
f3b7d47
Compare
a0bdb21
to
fbf1c4e
Compare
fbf1c4e
to
8a99960
Compare
@tertsdiepraam i believe i have adjusted the code according to your review. As its a big change of the library, take your time to review it. |
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.
Nice! This is almost ready to be merged, just some small final things to clean up.
Create new file parse_relative_time.rs with the relative time helper function. Renames from_str to parse_datetime and parse_relative time. Adds function parse_datetime_at_date.
8a99960
to
f10749e
Compare
@tertsdiepraam i believe i fixed all issues. |
@philolo1 is it by design that parse_relative_time is private?
|
@sylvestre i am sorry I do not remember why we only exposed one function. I dont see any issue also exposing this function. |
@philolo1 yeah, it is significantly reducing the scope of this crate :) could you please make the change? thanks |
Sure i can do it either today or tomorrow @sylvestre , then we should create a new version |
actually, i did it here :) |
Thanks
…On Sat, Sep 23, 2023 at 17:41 Sylvestre Ledru ***@***.***> wrote:
actually, i did it here :)
#50 <#50>
—
Reply to this email directly, view it on GitHub
<#33 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABP4LZTN6DPSMFCAIRAQVKLX32OB7ANCNFSM6AAAAAA3YHMPWE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yes, there's a good reason not to do relative time only, because a relative time on its own is undefined. For example, if we get a relative time of "1 month", how many days should we go forward? We've tried to work around this a bit, but that makes it more difficult. Instead we should always parse the full datetime relative to some reference datetime (which is the current time by default). So, in that format both "tomorrow" and "2023-09-23" are supported. I don't think there's anything in the coreutils that accept only a relative time, but not an absolute time as well. We haven't reduced the scope of the crate because the |
oh ok, my bad :) |
@tertsdiepraam @sylvestre
As discussed in uutils/coreutils#5181, this makes parse_dateime::parse_datetime::from_str accept relative time.