-
Notifications
You must be signed in to change notification settings - Fork 113
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
ts argument for the current week? #48
Comments
Hi, Please see the documentation for the timestamp-based predicates:
|
I see that, but I'm still a bit confused. I suppose I would've expected a keyword like |
The only keyword at the moment is You can, of course, use specific dates corresponding to the range you want. You can find an example of a helper function here: https://github.com/alphapapa/ts.el Search the readme for |
@FTWynn You can check my config. https://github.com/forrestchang/.doom.d/blob/master/modules/private/my-org/config.el#L166 (defun current-week-range ()
"Return timestamps (BEG . END) spanning current calendar week."
(let* (;; Bind `now' to the current timestamp to ensure all calculations
;; begin from the same timestamp. (In the unlikely event that
;; the execution of this code spanned from one day into the next,
;; that would cause a wrong result.)
(now (ts-now))
;; We start by calculating the offsets for the beginning and
;; ending timestamps using the current day of the week. Note
;; that the `ts-dow' slot uses the "%w" format specifier, which
;; counts from Sunday to Saturday as a number from 0 to 6.
(adjust-beg-day (- 1 (ts-dow now)))
(adjust-end-day (- 7 (ts-dow now)))
;; Make beginning/end timestamps based on `now', with adjusted
;; day and hour/minute/second values. These functions return
;; new timestamps, so `now' is unchanged.
(beg (thread-last now
;; `ts-adjust' makes relative adjustments to timestamps.
(ts-adjust 'day adjust-beg-day)
;; `ts-apply' applies absolute values to timestamps.
(ts-apply :hour 0 :minute 0 :second 0)))
(end (thread-last now
(ts-adjust 'day adjust-end-day)
(ts-apply :hour 23 :minute 59 :second 59))))
(cons beg end)))
;; Weekly Review
(defun custom-ql-weekly-review ()
(interactive)
(let* ((ts-default-format "%Y-%m-%d")
(beg (ts-format (car (current-week-range))))
(end (ts-format (cdr (current-week-range)))))
(org-ql-search (org-agenda-files)
`(and (todo "TODO" "STARTED" "BLOCKED" "DONE")
(tags "PROJ")
(or (deadline :from ,beg :to ,end)
(closed :from ,beg :to ,end)))
:title "Weekly Review"
:super-groups '((:name "STARTED"
:todo "STARTED")
(:name "TODO"
:todo "TODO")
(:name "BLOCKED"
:todo "BLOCKED")
(:name "DONE"
:todo "DONE"))
))) |
Just in case if someone find its useful, I've extended this snippet for my use to be able to go back as many weeks in the past as I want:
I believe org-ql users would benefit a lot having 'thisweek', 'thismonth' and 'thisyear' duration tags. So one can actually write something like: |
Something like that could be useful, yes. It would need a clear and unambiguous API. For example, does Because of that ambiguity, I'd generally be in favor of something more flexible and less ambiguous, even if it were a bit more verbose. e.g. Another possibility might be something like If the documentation were clear enough, something like this might also work:
If you want to submit PRs, I'm open to them, but please construct them carefully. For example, adding a Then, assuming that Finally, any new arguments and functions like that need to have tests as well. The "paperwork" sometimes produces more lines in the diff than the actual code, but it's necessary for the quality of the project. And if a PR submitter doesn't submit those parts, I end up having to do them myself, which isn't as much fun as writing code. ;) |
Is there now a general way to retrieve current week, month, or year for org-ql ts arguments? |
Hello alphapapa, and thank you so much for this great tool!
Is there any way to query for timestamps within the current week (like the default org agenda view)? I see how it's possible to do 7 days prior, but I'd like to drop last week's tail items if possible.
I could imagine doing it either in the query or in a :discard group, but I'm not sure what selector I would use.
Any guidance would be greatly appreciated!
The text was updated successfully, but these errors were encountered: