From mboxrd@z Thu Jan 1 00:00:00 1970 From: thunk2@arcor.de (Thomas Plass) Subject: Re: insert date-stamp for one month Date: Sun, 18 Aug 2019 12:02:31 +0200 Message-ID: <23897.8759.759508.760331@AGAME7.local> References: <87a7c6rjl4.fsf@mat.ucm.es> Reply-To: Thomas Plass Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:58521) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzI1g-0006Qx-Gg for emacs-orgmode@gnu.org; Sun, 18 Aug 2019 06:03:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzI1b-0006uH-C7 for emacs-orgmode@gnu.org; Sun, 18 Aug 2019 06:03:04 -0400 Received: from vsmx009.vodafonemail.xion.oxcs.net ([153.92.174.87]:9008) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hzI1X-0006p9-VW for emacs-orgmode@gnu.org; Sun, 18 Aug 2019 06:02:59 -0400 In-Reply-To: Your message of Sunday, August 18 2019 09:58:15 (ID: <87a7c6rjl4.fsf@mat.ucm.es>). List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Uwe Brauer Cc: emacs-orgmode@gnu.org 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