From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Insert Todays Date Plus Ten Days Date: Mon, 22 Oct 2012 09:48:58 +0200 Message-ID: <87pq4bgd5h.fsf@web.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1350892136 29667 80.91.229.3 (22 Oct 2012 07:48:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 22 Oct 2012 07:48:56 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 22 09:49:03 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TQCkw-0007KB-SD for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Oct 2012 09:49:02 +0200 Original-Received: from localhost ([::1]:50451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQCkp-0003Ap-HC for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Oct 2012 03:48:55 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:33055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQCkk-0003AK-6m for help-gnu-emacs@gnu.org; Mon, 22 Oct 2012 03:48:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQCke-0007rH-Ee for help-gnu-emacs@gnu.org; Mon, 22 Oct 2012 03:48:50 -0400 Original-Received: from mout.web.de ([212.227.15.4]:57321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQCke-0007oC-3m for help-gnu-emacs@gnu.org; Mon, 22 Oct 2012 03:48:44 -0400 Original-Received: from drachen.dragon ([82.113.98.221]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0M73SD-1TBxka3t8X-00xGDV; Mon, 22 Oct 2012 09:48:42 +0200 Mail-Followup-To: help-gnu-emacs@gnu.org In-Reply-To: (Esben Stien's message of "Mon, 22 Oct 2012 01:53:24 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-Provags-ID: V02:K0:LR0OHaajtqeCy256oz3K08FNFo7QYOLPElqCiGYLu2u CfUyMdC5OO5QMidpVp3uqSFVjvxXRR6WMq3BC/v6h71g/zhKpk Ynx7uvWkspsZE9P7Fls00lklhzFjIvx8uvM71l+NDxBPoxjDb2 zIB6ntX85r6JnXSRhOCtx8Rt0ogBb+BwkUMHE4+01INZGftiXa 3m1aYNGvlLDNBivt5ZghgVoHCvsAgvMTV3iTTjZj6o= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.15.4 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87356 Archived-At: Hi Esben, I do it like that: (defun my-insert-date (&optional arg) "Insert current date at point. With prefix arg, add that many days." (interactive "*P") (insert (format-time-string "%Y_%m_%d" (time-add (days-to-time (if arg (prefix-numeric-value arg) 0)) (current-time))))) Michael. > I'm using this to insert todays date: > > ;;insert current date in ISO format,timestamp > (defun insert-date (prefix) > "Insert the current date. With prefix-argument, use ISO format. With > two prefix arguments, write out the day and month name." > (interactive "P") > (let ((format (cond > ;; ((not prefix) "%d.%m.%Y") > ((not prefix) "%Y-%m-%d") > ((equal prefix '(4)) "%Y-%m-%d") > ((equal prefix '(16)) "%A, %d. %B %Y"))) > (system-time-locale "nb_NO")) > (insert (format-time-string format)))) > > , but I'm unsure how I can insert the date in 10 days. > > There doesn't seem to be a way to do arithmetic on > format-time-string?;). > > Any pointers as to how I can do this?.