all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* a command to insert today's date OR time (or both)?
@ 2011-01-09  1:00 David Combs
  2011-01-09  3:30 ` Pascal J. Bourguignon
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: David Combs @ 2011-01-09  1:00 UTC (permalink / raw)
  To: help-gnu-emacs

I've looked in emacs' *info*, its list of commands, etc,
and can find nothing.

Sure would be nice to be to easily to insert the current
date, time, or both.

Thanks!

David



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

* Re: a command to insert today's date OR time (or both)?
  2011-01-09  1:00 a command to insert today's date OR time (or both)? David Combs
@ 2011-01-09  3:30 ` Pascal J. Bourguignon
  2011-01-09 12:06   ` Gregor Zattler
  2011-01-09  5:19 ` Udyant Wig
  2011-01-09 14:32 ` Drew Adams
  2 siblings, 1 reply; 10+ messages in thread
From: Pascal J. Bourguignon @ 2011-01-09  3:30 UTC (permalink / raw)
  To: help-gnu-emacs

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.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


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

* Re: a command to insert today's date OR time (or both)?
  2011-01-09  1:00 a command to insert today's date OR time (or both)? David Combs
  2011-01-09  3:30 ` Pascal J. Bourguignon
@ 2011-01-09  5:19 ` Udyant Wig
  2011-01-09  5:30   ` Udyant Wig
  2011-01-09 14:23   ` Drew Adams
  2011-01-09 14:32 ` Drew Adams
  2 siblings, 2 replies; 10+ messages in thread
From: Udyant Wig @ 2011-01-09  5:19 UTC (permalink / raw)
  To: help-gnu-emacs

dkcombs@panix.com (David Combs) writes:

| I've looked in emacs' *info*, its list of commands, etc,
| and can find nothing.
|
| Sure would be nice to be to easily to insert the current
| date, time, or both.
|
| Thanks!
|
| David

Apart from what Pascal suggested, you could try these:

(defun insert-current-time ()
  (interactive)
  (destructuring-bind
        (sec min hour day month year dow dst zone)
      (decode-time)
      (insert (format "%02d:%02d:%02d" hour min sec))))

(defun insert-current-date ()
  (interactive)
  (let ((days '((0 . Sunday)
                (1 . Monday)
                (2 . Tuesday)
                (3 . Wednesday)
                (4 . Thursday)
                (5 . Friday)
                (6 . Saturday)))
        (months '((1 . Jan)
                  (2 . Feb)
                  (3 . Mar)
                  (4 . Apr)
                  (5 . May)
                  (6 . Jun)
                  (7 . Jul)
                  (8 . Aug)
                  (9 . Sep)
                  (10 . Oct)
                  (11 . Nov)
                  (12 . Dec))))
    (destructuring-bind
          (sec min hour day month year dow dst zone)
        (decode-time)
      (insert (format "%s, %d %s %d"
                      (rest (assoc dow days))
                      day
                      (rest (assoc month months))
                      year)))))

You could, of course, combine these as:

(defun insert-current-time-date ()
  (interactive)
  (insert-current-time)
  (insert (format "  "))
  (insert-current-date))

Or whichever way you want them.

P.S. Suggested improvements gladly accepted.


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

* Re: a command to insert today's date OR time (or both)?
  2011-01-09  5:19 ` Udyant Wig
@ 2011-01-09  5:30   ` Udyant Wig
  2011-01-09 14:23   ` Drew Adams
  1 sibling, 0 replies; 10+ messages in thread
From: Udyant Wig @ 2011-01-09  5:30 UTC (permalink / raw)
  To: help-gnu-emacs

Udyant Wig <udyantw@gmail.com> writes:

| dkcombs@panix.com (David Combs) writes:
|
| | I've looked in emacs' *info*, its list of commands, etc,
| | and can find nothing.
| |
| | Sure would be nice to be to easily to insert the current
| | date, time, or both.
| |
| | Thanks!
| |
| | David
| <Reply elided>

You'll want to do a
 (require 'cl)
before using that.

Sorry for the omission.


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

* Re: a command to insert today's date OR time (or both)?
  2011-01-09  3:30 ` Pascal J. Bourguignon
@ 2011-01-09 12:06   ` Gregor Zattler
  0 siblings, 0 replies; 10+ messages in thread
From: Gregor Zattler @ 2011-01-09 12:06 UTC (permalink / raw)
  To: help-gnu-emacs

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



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

* RE: a command to insert today's date OR time (or both)?
  2011-01-09  5:19 ` Udyant Wig
  2011-01-09  5:30   ` Udyant Wig
@ 2011-01-09 14:23   ` Drew Adams
  1 sibling, 0 replies; 10+ messages in thread
From: Drew Adams @ 2011-01-09 14:23 UTC (permalink / raw)
  To: help-gnu-emacs

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




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

* RE: a command to insert today's date OR time (or both)?
  2011-01-09  1:00 a command to insert today's date OR time (or both)? David Combs
  2011-01-09  3:30 ` Pascal J. Bourguignon
  2011-01-09  5:19 ` Udyant Wig
@ 2011-01-09 14:32 ` Drew Adams
  2011-01-09 14:42   ` Le Wang
       [not found]   ` <mailman.18.1294584142.18702.help-gnu-emacs@gnu.org>
  2 siblings, 2 replies; 10+ messages in thread
From: Drew Adams @ 2011-01-09 14:32 UTC (permalink / raw)
  To: 'David Combs', help-gnu-emacs

> I've looked in emacs' *info*, its list of commands, etc,
> and can find nothing.

You forgot Emacs Wiki: http://www.emacswiki.org/.

Just type "insert date" into the search field - voila!




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

* Re: a command to insert today's date OR time (or both)?
  2011-01-09 14:32 ` Drew Adams
@ 2011-01-09 14:42   ` Le Wang
       [not found]   ` <mailman.18.1294584142.18702.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Le Wang @ 2011-01-09 14:42 UTC (permalink / raw)
  To: Drew Adams; +Cc: David Combs, help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 390 bytes --]

You also forgot google.  The wiki link was the first result when I searched
Emacs + this subject.

On Sun, Jan 9, 2011 at 10:32 PM, Drew Adams <drew.adams@oracle.com> wrote:

> > I've looked in emacs' *info*, its list of commands, etc,
> > and can find nothing.
>
> You forgot Emacs Wiki: http://www.emacswiki.org/.
>
> Just type "insert date" into the search field - voila!
>
>
>


-- 
Le

[-- Attachment #2: Type: text/html, Size: 777 bytes --]

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

* Re: a command to insert today's date OR time (or both)?
       [not found]   ` <mailman.18.1294584142.18702.help-gnu-emacs@gnu.org>
@ 2011-01-21  1:33     ` David Combs
  2011-01-21 11:36       ` ken
  0 siblings, 1 reply; 10+ messages in thread
From: David Combs @ 2011-01-21  1:33 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.18.1294584142.18702.help-gnu-emacs@gnu.org>,
Le Wang  <l26wang@gmail.com> wrote:
>-=-=-=-=-=-
>
>You also forgot google.  The wiki link was the first result when I searched
>Emacs + this subject.
>
>On Sun, Jan 9, 2011 at 10:32 PM, Drew Adams <drew.adams@oracle.com> wrote:
>
>> > I've looked in emacs' *info*, its list of commands, etc,
>> > and can find nothing.
>>
>> You forgot Emacs Wiki: http://www.emacswiki.org/.
>>
>> Just type "insert date" into the search field - voila!
>>
>>
>>
>
>
>-- 
>Le
>
>-=-=-=-=-=-
>[Alternative: text/html]
>-=-=-=-=-=-

THANKS EVERYONE!, for all the different ways of doing it!

David



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

* Re: a command to insert today's date OR time (or both)?
  2011-01-21  1:33     ` David Combs
@ 2011-01-21 11:36       ` ken
  0 siblings, 0 replies; 10+ messages in thread
From: ken @ 2011-01-21 11:36 UTC (permalink / raw)
  To: GNU Emacs List

A couple years ago I posted code to insert the current date and/or the
current time (and other functionality, e.g., yesterday's date,
tomorrow's date) to the emacs wiki.  Oddly, that wiki page didn't turn
up in several different searches... I found it only after browsing the
Categories.  To save you some time, it's here:

<http://www.emacswiki.org/emacs/Journal>



On 01/20/2011 08:33 PM David Combs wrote:
> In article <mailman.18.1294584142.18702.help-gnu-emacs@gnu.org>,
> Le Wang  <l26wang@gmail.com> wrote:
>> -=-=-=-=-=-
>>
>> You also forgot google.  The wiki link was the first result when I searched
>> Emacs + this subject.
>>
>> On Sun, Jan 9, 2011 at 10:32 PM, Drew Adams <drew.adams@oracle.com> wrote:
>>
>>>> I've looked in emacs' *info*, its list of commands, etc,
>>>> and can find nothing.
>>> You forgot Emacs Wiki: http://www.emacswiki.org/.
>>>
>>> Just type "insert date" into the search field - voila!
>>>
>>>
>>>
>>
>> -- 
>> Le
>>
>> -=-=-=-=-=-
>> [Alternative: text/html]
>> -=-=-=-=-=-
> 
> THANKS EVERYONE!, for all the different ways of doing it!
> 
> David
> 



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

end of thread, other threads:[~2011-01-21 11:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-09  1:00 a command to insert today's date OR time (or both)? David Combs
2011-01-09  3:30 ` Pascal J. Bourguignon
2011-01-09 12:06   ` Gregor Zattler
2011-01-09  5:19 ` Udyant Wig
2011-01-09  5:30   ` Udyant Wig
2011-01-09 14:23   ` Drew Adams
2011-01-09 14:32 ` Drew Adams
2011-01-09 14:42   ` Le Wang
     [not found]   ` <mailman.18.1294584142.18702.help-gnu-emacs@gnu.org>
2011-01-21  1:33     ` David Combs
2011-01-21 11:36       ` ken

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.