[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] insert date-stamp for one month
From: |
Thomas Plass |
Subject: |
Re: [O] insert date-stamp for one month |
Date: |
Sun, 18 Aug 2019 12:02:31 +0200 |
Hello,
Uwe Brauer wrote at 09:58 on August 18, 2019:
: I sometimes need to insert a date-stamp which corresponds to one month
: in a year, say march 2019. I usually insert
: <2019-03-01 Fri>--<2019-03-31 Sun>, but this is cumbersome to do
: manually.
This'll put the computed result on the kill ring. Beautification and
error checking of input values left as an exercise for the reader.
(defun Brauer/make-month-timerange (year month)
(interactive
(list (string-to-int (read-string "Year: " (int-to-string (nth 5
(decode-time)))))
(string-to-int (read-string "Month: " (int-to-string (nth 4
(decode-time)))))))
(let* ((last-day (calendar-last-day-of-month month year))
(start (list 0 0 0 1 month year))
(end (list 0 0 0 last-day month year))
(ts (format "<%d-%02d-%02d %s>--<%d-%02d-%02d %s>"
year month 1 (format-time-string "%a" (apply #'encode-time
start))
year month last-day (format-time-string "%a" (apply
#'encode-time end)))))
(message (substitute-command-keys (concat "Use \\[yank] to yank " ts)))
(kill-new ts)))
Regards
Thomas