-
Notifications
You must be signed in to change notification settings - Fork 15
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
[Q/FR] Support for relative dates #4
Comments
I would like to, yes. The easiest solution would be to call out to GNU
date, which has great natural language support, but it isn't available by
default on Mac or BSD. I suppose we could port one of the nice Python libs,
but that would be a lot of work.
…On Feb 26, 2019 10:28 AM, "Matus Goljer" ***@***.***> wrote:
Do you plan to support relative dates with a human readable instructions,
like "last year" or "next month"... I would like to have something to parse
these relative to today (or an argument passed in). But also it should
understand input such as "2018" or "jan 2018" to give the specified
intervals.
My current use-case is to make better reports for org-clock-budget where
you could specify the intervals/periods with a simple query such as "last
year" or "this week" and it will give you a report. This way users can view
historical reports as well as the current ones.
It feels like it might be a separate package, "period" or something for
returning the intervals specified by the query.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAktFdKnQeqjCPkw2sgpEsfGSBZEKV1Hks5vRWDBgaJpZM4bSlLu>
.
|
@Fuco1 FYI, I just updated this package, fixing all warnings, adding tests, adding docs, and submitting to MELPA. Please let me know if you have any feedback. |
I think it may be possible to support this without implementing plain-language parsing. For example, the example added in e3e32eb shows a simple function that returns the timestamps at the beginning and end of the week containing a given timestamp. It would be easy to have similar functions for week-start, year-end, etc, and compose those into "last year," "last week," etc. Year start/end would be very easy with (defun ts-year-span (ts)
(let* ((beg (ts-apply :month 1 :day 1 :hour 0 :minute 0 :second 0 ts))
(end (ts-apply :month 12 :day 31 :hour 23 :minute 59 :second 59 ts)))
(cons beg end)))
(-let (((beg . end) (ts-year-span (ts-now))))
(cons (ts-format beg)
(ts-format end)))
;;=> ("2019-01-01 00:00:00 -0600" . "2019-12-31 23:59:59 -0600") |
Do you plan to support relative dates with a human readable instructions, like "last year" or "next month"... I would like to have something to parse these relative to today (or an argument passed in). But also it should understand input such as "2018" or "jan 2018" to give the specified intervals.
My current use-case is to make better reports for org-clock-budget where you could specify the intervals/periods with a simple query such as "last year" or "this week" and it will give you a report. This way users can view historical reports as well as the current ones.
It feels like it might be a separate package, "period" or something for returning the intervals specified by the query.
Edit: the inspiration comes from ledger https://github.com/ledger/ledger/blob/7c0ae5b02571e21f97d45f5d091cb78af9885713/src/times.cc and how it handles relative times. Maybe I will try to port it using ts as a backend.
The text was updated successfully, but these errors were encountered: