From: Uwe Brauer <oub@mat.ucm.es>
To: emacs-orgmode@gnu.org
Subject: Re: insert date-stamp for one month
Date: Sun, 18 Aug 2019 12:21:17 +0200 [thread overview]
Message-ID: <8736hypyea.fsf@mat.ucm.es> (raw)
In-Reply-To: 23897.8759.759508.760331@AGAME7.local
[-- Attachment #1: Type: text/plain, Size: 1998 bytes --]
>>> "TP" == Thomas Plass <thunk2@arcor.de> writes:
> 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)))
Very cool, thanks a lot. But why no
(defun Plass/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)))))
(insert ts)))
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5025 bytes --]
next prev parent reply other threads:[~2019-08-18 10:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-18 7:58 insert date-stamp for one month Uwe Brauer
2019-08-18 10:02 ` Thomas Plass
2019-08-18 10:21 ` Uwe Brauer [this message]
2019-08-18 14:33 ` [week?] (was: insert date-stamp for one month) Uwe Brauer
2019-08-19 12:29 ` Thomas Plass
2019-08-18 10:26 ` insert date-stamp for one month Ken Mankoff
2019-08-18 10:37 ` Uwe Brauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8736hypyea.fsf@mat.ucm.es \
--to=oub@mat.ucm.es \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.