[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: a command to insert today's date OR time (or both)?
From: |
Gregor Zattler |
Subject: |
Re: a command to insert today's date OR time (or both)? |
Date: |
Sun, 9 Jan 2011 13:06:41 +0100 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Hi Pascal,
* Pascal J. Bourguignon <pjb@informatimago.com> [09. Jan. 2011]:
> dkcombs@panix.com (David Combs) writes:
>
>> I've looked in emacs' *info*, its list of commands, etc,
>> and can find nothing.
>
> C-u M-! date RET
> Sun Jan 9 04:29:12 CET 2011
>
> C-u M-: (calendar-current-date) RET
> (1 9 2011)
>
>> Sure would be nice to be to easily to insert the current
>> date, time, or both.
>
> Then write the command to do so.
> Notice how each user will want to insert it in a different format.
Stolen from some website:
(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. With
three (!) prefix arguments give date and time in ISO Format
and append day and month name in brackets"
(interactive "P")
(let ((format (cond
((not prefix) "%d.%m.%Y")
((equal prefix '(4)) "%Y-%m-%d")
((equal prefix '(16)) "%A, %d. %B %Y")))
(system-time-locale "de_DE"))
(insert (format-time-string format))))
(global-set-key (kbd "C-c d") 'insert-date)
Ciao, Gregor
--
-... --- .-. . -.. ..--.. ...-.-