[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Insert Todays Date Plus Ten Days
From: |
Michael Heerdegen |
Subject: |
Re: Insert Todays Date Plus Ten Days |
Date: |
Mon, 22 Oct 2012 09:48:58 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) |
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?.