when
when copied to clipboard
Can it determine distance from a static date?
For example, if I have a static value, such as my birthday, could I enter something like "halfway through my 18th year"? Thus the distance would be birth_date + 18 years.
Hey @jwnacnud, thanks for the question.
Not really, because it doesn't return time.Duration but time.Time.
In order to infer the point in time, the static date should also be present in the parser's context, right? Like,
My BDay is on 12/09/1980 and I am halfway through my 18th year
Otherwise, you would need to return time.Duration from the parser and apply it later on. The latter, is not really possible as I mentioned above. However, the former can be done with a planned merge strategy. But it's not implemented yet. Please feel free to propose a solution for that!
Best regards, Oleg
In addition to the above, checked the code once again, I think we can add Duration to the Result object here so after that you will be able to create rules that capture durations like you mention.
That would be awesome.
Jeffrey Duncan
On Thu, Jun 1, 2023 at 5:02 PM Oleg Lebedev @.***> wrote:
In addition to the above, checked the code once again, I think we can add Duration to the Result object here https://github.com/olebedev/when/blob/master/when.go#L24-L33 so after that you will be able to create rules that capture durations like you mention.
— Reply to this email directly, view it on GitHub https://github.com/olebedev/when/issues/33#issuecomment-1572898403, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGW5A7KPG5AK7NX3FUAMATXJENO3ANCNFSM6AAAAAAULYUOYE . You are receiving this because you were mentioned.Message ID: @.***>