Skip to content

Conversation

@JellyWX
Copy link

@JellyWX JellyWX commented May 16, 2021

This is still a draft- I haven't tested this fully yet.

1: timezone support

Just a case of going through and replacing NaiveDateTime with DateTime<T>. In the current iteration, Config must be initialized with a DateTime to fill out the type parameter. I'm trying to figure out if this can be avoided, to retain the old Config interface

...update on this, seems it can't be easily avoided since Chrono doesn't expose a now method on TimeZone. So this is an unfortunate breaking change

2: support 'in x units'

Parser can now handle 'in 10 seconds', 'in 12 days', etc.
Again, this is still pretty draft. I need to go through and check it hasn't disrupted any other parsing, and that it will recognise other common phrases like 'in a day', or 'in a week'.

3: allow 'on', 'a', 'an' prefixes

Parser can handle 'on Friday', 'in an hour', 'a minute before 8pm', etc.

4: add config option to aid with 'in a day'/'a day from now' parser patterns

Potentially there was just a bug here and so this config option should be taken out, however 'a day from now' would return the entire period encapsulating that day, rather than the instant that is one day from now. The config option 'select_instant' fixes this

Other stuff changed:

  • A couple of extra gitignore lines just to shut my IDE up.
  • Config no longer clones itself when building

@JellyWX JellyWX marked this pull request as ready for review May 16, 2021 19:55
@dfhoughton
Copy link
Owner

@JellyWX , first of all, thank you for taking to trouble to submit this pull request. You should know up front that it will take me a little while to give this proper attention.

  1. working in Rust isn't my day job
  2. this is no longer my main side project or a component of my main side project
  3. I have other project which do take up my time nowadays
  4. I am not as industrious as one might desire

Before I get to any reviewing, which in any case won't happen today, a few points. Is the new functionality in here something that you yourself need? If this isn't answering an immediate need or fixing an existing bug, I'm a little reluctant to merge it. Every feature added imposes a cost on future maintenance, and as I said above I'm a little lazy. I notice you didn't add any tests aside from a what I assume is a proof of concept executable. The tests are easy to write now that there's a pattern to follow.

Anyway, again, thank you. I'll try to keep this on my queue to review soon.

@JellyWX
Copy link
Author

JellyWX commented May 17, 2021

No problem, totally understand.

And yes, I'm going to try and adapt this to replace dateparser's functionality in one of my projects. I've already found a few strange edge cases for the parser that for some reason dateparser will process and people are actively using. So I'll continue to expand that on my own fork.

I understand not wanting to add additional functionality. I can write up some tests anyway, but potentially it'd be good to just keep myself a separate fork, since there's a lot of stuff that I don't need and don't want to maintain like the SMALL_GRAMMAR and period selection, and possibly lots of weird parser cases I'll need to add

@berkus
Copy link

berkus commented Aug 13, 2025

Hi!

I am very much in need of "in X units" functionality, do you have any plans to merge this? It's been a few years now.

@dfhoughton
Copy link
Owner

Hi!

I am very much in need of "in X units" functionality, do you have any plans to merge this? It's been a few years now.

I will look into this this coming weekend.

@JellyWX
Copy link
Author

JellyWX commented Aug 18, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants