all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Insert Todays Date Plus Ten Days
Date: Mon, 22 Oct 2012 09:48:58 +0200	[thread overview]
Message-ID: <87pq4bgd5h.fsf@web.de> (raw)
In-Reply-To: <mailman.11407.1350861900.855.help-gnu-emacs@gnu.org> (Esben Stien's message of "Mon, 22 Oct 2012 01:53:24 +0200")

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?. 



       reply	other threads:[~2012-10-22  7:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.11407.1350861900.855.help-gnu-emacs@gnu.org>
2012-10-22  7:48 ` Michael Heerdegen [this message]
2012-10-22 17:09   ` Insert Todays Date Plus Ten Days Esben Stien
2012-10-21 23:53 Esben Stien
2012-10-21 23:34 ` Drew Adams

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=87pq4bgd5h.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=help-gnu-emacs@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.