I'm trying to build functions that help me execute frequent sparse tree queries, using org-match-sparse-tree nil "<some_query>"
in my code.
Some of these queries need to contain constraints such as SCHEDULED<=<end_of_this_month>
, where <end_of_this_month>
just means the end of the current month. The same could be true for this week, next week, this year, and so on.
I know about the possibility of writing SCHEDULED<=<1+y>
, but that just means 1 year from now, meaning, as of the time of this writing, from Aug 28 2019 to Aug 27 2020, which is not what I want.
Is there a way to, programmatically, obtain in a string the end of the current or next month/year/week without having to manually calculate those (meaning using a preexisting date-handling function)?
calendar.el
library has a function:(calendar-last-day-of-month MONTH YEAR)
. There is probably a buit-in function to obtain the current month / year, but if not, you can extract it form(current-time)
and/orformat-time-string
that defaults to the current time ..... See alsoorg-time-today
,parse-time-string
andorg-parse-time-string
... – lawlist Aug 28 '19 at 21:32elmo.el
library that has a function that is easily extracted/separated calledelmo-time-to-datevec
(which relies on the built-intimezone.el
library) -- see github.com/wanderlust/wanderlust/blob/master/elmo/elmo-date.el E.g.,(elmo-time-to-datevec (current-time))
at this precise moment in time returns[2019 8 28 14 50 56 (-25200 "PDT")]
and we can then extract thenth
element from the vector ... – lawlist Aug 28 '19 at 21:50(calendar-last-day-of-month (string-to-number (format-time-string "%m")) (string-to-number (format-time-string "%y")))
– Ivan Perez Aug 28 '19 at 21:52last-day-of-week
... andersen.berlin/emacs.d I have not studied to see who wrote it .... The result is in time and needs to be converted ... – lawlist Aug 28 '19 at 22:01