unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* RE: Insert Todays Date Plus Ten Days
  2012-10-21 23:53 Esben Stien
@ 2012-10-21 23:34 ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2012-10-21 23:34 UTC (permalink / raw)
  To: 'Esben Stien', help-gnu-emacs

> , but I'm unsure how I can insert the date in 10 days. 

This might help (dunno, I don't use such things):

http://www.emacswiki.org/emacs/InsertingAndUpdatingDates




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Insert Todays Date Plus Ten Days
@ 2012-10-21 23:53 Esben Stien
  2012-10-21 23:34 ` Drew Adams
  0 siblings, 1 reply; 4+ messages in thread
From: Esben Stien @ 2012-10-21 23:53 UTC (permalink / raw)
  To: help-gnu-emacs

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

-- 
Esben Stien is b0ef@e     s      a             
         http://www. s     t    n m
          irc://irc.  b  -  i  .   e/%23contact
           sip:b0ef@   e     e 
           jid:b0ef@    n     n



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Insert Todays Date Plus Ten Days
       [not found] <mailman.11407.1350861900.855.help-gnu-emacs@gnu.org>
@ 2012-10-22  7:48 ` Michael Heerdegen
  2012-10-22 17:09   ` Esben Stien
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Heerdegen @ 2012-10-22  7:48 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Insert Todays Date Plus Ten Days
  2012-10-22  7:48 ` Insert Todays Date Plus Ten Days Michael Heerdegen
@ 2012-10-22 17:09   ` Esben Stien
  0 siblings, 0 replies; 4+ messages in thread
From: Esben Stien @ 2012-10-22 17:09 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

> (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)))))

That's really excellent;). Thanks. 

-- 
Esben Stien is b0ef@e     s      a             
         http://www. s     t    n m
          irc://irc.  b  -  i  .   e/%23contact
           sip:b0ef@   e     e 
           jid:b0ef@    n     n



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-10-22 17:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.11407.1350861900.855.help-gnu-emacs@gnu.org>
2012-10-22  7:48 ` Insert Todays Date Plus Ten Days Michael Heerdegen
2012-10-22 17:09   ` Esben Stien
2012-10-21 23:53 Esben Stien
2012-10-21 23:34 ` Drew Adams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).