* insert date-stamp for one month
@ 2019-08-18 7:58 Uwe Brauer
2019-08-18 10:02 ` Thomas Plass
2019-08-18 10:26 ` insert date-stamp for one month Ken Mankoff
0 siblings, 2 replies; 7+ messages in thread
From: Uwe Brauer @ 2019-08-18 7:58 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 295 bytes --]
Hi
I sometimes need to insert a date-stamp which corresponds to one month
in a year, say march 2019. I usually insert
<2019-03-01 Fri>--<2019-03-31 Sun>, but this is cumbersome to do
manually.
Somebody has a better idea or know how to insert something like <03.2019>
Uwe Brauer
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5025 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: insert date-stamp for one month
2019-08-18 7:58 insert date-stamp for one month Uwe Brauer
@ 2019-08-18 10:02 ` Thomas Plass
2019-08-18 10:21 ` Uwe Brauer
2019-08-18 14:33 ` [week?] (was: insert date-stamp for one month) Uwe Brauer
2019-08-18 10:26 ` insert date-stamp for one month Ken Mankoff
1 sibling, 2 replies; 7+ messages in thread
From: Thomas Plass @ 2019-08-18 10:02 UTC (permalink / raw)
To: Uwe Brauer; +Cc: emacs-orgmode
Hello,
Uwe Brauer wrote at 09:58 on August 18, 2019:
: I sometimes need to insert a date-stamp which corresponds to one month
: in a year, say march 2019. I usually insert
: <2019-03-01 Fri>--<2019-03-31 Sun>, but this is cumbersome to do
: manually.
This'll put the computed result on the kill ring. Beautification and
error checking of input values left as an exercise for the reader.
(defun Brauer/make-month-timerange (year month)
(interactive
(list (string-to-int (read-string "Year: " (int-to-string (nth 5 (decode-time)))))
(string-to-int (read-string "Month: " (int-to-string (nth 4 (decode-time)))))))
(let* ((last-day (calendar-last-day-of-month month year))
(start (list 0 0 0 1 month year))
(end (list 0 0 0 last-day month year))
(ts (format "<%d-%02d-%02d %s>--<%d-%02d-%02d %s>"
year month 1 (format-time-string "%a" (apply #'encode-time start))
year month last-day (format-time-string "%a" (apply #'encode-time end)))))
(message (substitute-command-keys (concat "Use \\[yank] to yank " ts)))
(kill-new ts)))
Regards
Thomas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: insert date-stamp for one month
2019-08-18 10:02 ` Thomas Plass
@ 2019-08-18 10:21 ` Uwe Brauer
2019-08-18 14:33 ` [week?] (was: insert date-stamp for one month) Uwe Brauer
1 sibling, 0 replies; 7+ messages in thread
From: Uwe Brauer @ 2019-08-18 10:21 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1998 bytes --]
>>> "TP" == Thomas Plass <thunk2@arcor.de> writes:
> Hello,
> Uwe Brauer wrote at 09:58 on August 18, 2019:
> : I sometimes need to insert a date-stamp which corresponds to one month
> : in a year, say march 2019. I usually insert
> : <2019-03-01 Fri>--<2019-03-31 Sun>, but this is cumbersome to do
> : manually.
> This'll put the computed result on the kill ring. Beautification and
> error checking of input values left as an exercise for the reader.
> (defun Brauer/make-month-timerange (year month)
> (interactive
> (list (string-to-int (read-string "Year: " (int-to-string (nth 5 (decode-time)))))
> (string-to-int (read-string "Month: " (int-to-string (nth 4 (decode-time)))))))
> (let* ((last-day (calendar-last-day-of-month month year))
> (start (list 0 0 0 1 month year))
> (end (list 0 0 0 last-day month year))
> (ts (format "<%d-%02d-%02d %s>--<%d-%02d-%02d %s>"
> year month 1 (format-time-string "%a" (apply #'encode-time start))
> year month last-day (format-time-string "%a" (apply #'encode-time end)))))
> (message (substitute-command-keys (concat "Use \\[yank] to yank " ts)))
> (kill-new ts)))
Very cool, thanks a lot. But why no
(defun Plass/make-month-timerange (year month)
(interactive
(list (string-to-int (read-string "Year: " (int-to-string (nth 5 (decode-time)))))
(string-to-int (read-string "Month: " (int-to-string (nth 4 (decode-time)))))))
(let* ((last-day (calendar-last-day-of-month month year))
(start (list 0 0 0 1 month year))
(end (list 0 0 0 last-day month year))
(ts (format "<%d-%02d-%02d %s>--<%d-%02d-%02d %s>"
year month 1 (format-time-string "%a" (apply #'encode-time start))
year month last-day (format-time-string "%a" (apply #'encode-time end)))))
(insert ts)))
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5025 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [week?] (was: insert date-stamp for one month)
2019-08-18 10:02 ` Thomas Plass
2019-08-18 10:21 ` Uwe Brauer
@ 2019-08-18 14:33 ` Uwe Brauer
2019-08-19 12:29 ` Thomas Plass
1 sibling, 1 reply; 7+ messages in thread
From: Uwe Brauer @ 2019-08-18 14:33 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]
>>> "TP" == Thomas Plass <thunk2@arcor.de> writes:
hi
> Hello,
I was wondering could that also be done for a week instead of a month
> (defun Brauer/make-month-timerange (year month)
> (interactive
> (list (string-to-int (read-string "Year: " (int-to-string (nth 5 (decode-time)))))
> (string-to-int (read-string "Month: " (int-to-string (nth 4 (decode-time)))))))
> (let* ((last-day (calendar-last-day-of-month month year))
> (start (list 0 0 0 1 month year))
> (end (list 0 0 0 last-day month year))
> (ts (format "<%d-%02d-%02d %s>--<%d-%02d-%02d %s>"
> year month 1 (format-time-string "%a" (apply #'encode-time start))
> year month last-day (format-time-string "%a" (apply #'encode-time end)))))
> (message (substitute-command-keys (concat "Use \\[yank] to yank " ts)))
> (kill-new ts)))
The problem seems to be that there is no function
calendar-last-day-of-week. I tried to play a little around but it seems difficult.
Anyhow
Uwe Brauer
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5025 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [week?] (was: insert date-stamp for one month)
2019-08-18 14:33 ` [week?] (was: insert date-stamp for one month) Uwe Brauer
@ 2019-08-19 12:29 ` Thomas Plass
0 siblings, 0 replies; 7+ messages in thread
From: Thomas Plass @ 2019-08-19 12:29 UTC (permalink / raw)
To: Uwe Brauer; +Cc: emacs-orgmode
Hello,
Uwe Brauer wrote at 16:33 on August 18, 2019:
: The problem seems to be that there is no function
: calendar-last-day-of-week.
Well, there is, it's called `calendar-week-end-day'.
This returns the index into 'calendar-day-name-array. Note that the
variable 'calendar-week-start-day should be set properly (it defaults
to 0 = $SUNDAY, while I set this to 1, meaning $MONDAY).
This will only get you as far as computing the name of the day.
Computing a date and/or timestamp for an instance of that day name
relative to a date is quite another matter. The file
calendar/time-date.el might provide useful stuff for doing so.
Thomas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: insert date-stamp for one month
2019-08-18 7:58 insert date-stamp for one month Uwe Brauer
2019-08-18 10:02 ` Thomas Plass
@ 2019-08-18 10:26 ` Ken Mankoff
2019-08-18 10:37 ` Uwe Brauer
1 sibling, 1 reply; 7+ messages in thread
From: Ken Mankoff @ 2019-08-18 10:26 UTC (permalink / raw)
To: Uwe Brauer; +Cc: emacs-orgmode
On 2019-08-18 at 03:58 -04, Uwe Brauer <oub@mat.ucm.es> wrote...
> I sometimes need to insert a date-stamp which corresponds to one month
> in a year, say march 2019. I usually insert <2019-03-01
> Fri>--<2019-03-31 Sun>, but this is cumbersome to do manually.
>
> Somebody has a better idea or know how to insert something like <03.2019>
What about picking one day in the month, but only displaying the month?
e.g. https://emacs.stackexchange.com/questions/2243/how-can-i-change-org-mode-time-format-for-one-buffer
https://stackoverflow.com/questions/50233694/org-mode-edit-timestamp-with-custom-format
https://emacs.stackexchange.com/questions/32889/can-the-format-of-a-timestamp-in-an-org-mode-document-be-locally-adjusted-for-ex
-k.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: insert date-stamp for one month
2019-08-18 10:26 ` insert date-stamp for one month Ken Mankoff
@ 2019-08-18 10:37 ` Uwe Brauer
0 siblings, 0 replies; 7+ messages in thread
From: Uwe Brauer @ 2019-08-18 10:37 UTC (permalink / raw)
To: Ken Mankoff; +Cc: Uwe Brauer, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1024 bytes --]
>>> "KM" == Ken Mankoff <mankoff@gmail.com> writes:
> On 2019-08-18 at 03:58 -04, Uwe Brauer <oub@mat.ucm.es> wrote...
>> I sometimes need to insert a date-stamp which corresponds to one month
>> in a year, say march 2019. I usually insert <2019-03-01
Fri> --<2019-03-31 Sun>, but this is cumbersome to do manually.
>>
>> Somebody has a better idea or know how to insert something like <03.2019>
> What about picking one day in the month, but only displaying the month?
> e.g. https://emacs.stackexchange.com/questions/2243/how-can-i-change-org-mode-time-format-for-one-buffer
> https://stackoverflow.com/questions/50233694/org-mode-edit-timestamp-with-custom-format
> https://emacs.stackexchange.com/questions/32889/can-the-format-of-a-timestamp-in-an-org-mode-document-be-locally-adjusted-for-ex
Thanks, but this is either buffer or export specific, I want it for some
entries but not for all in my buffer. So Thomas solution, was precisely
what I was looking for.
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5025 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-08-19 12:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-18 7:58 insert date-stamp for one month Uwe Brauer
2019-08-18 10:02 ` Thomas Plass
2019-08-18 10:21 ` Uwe Brauer
2019-08-18 14:33 ` [week?] (was: insert date-stamp for one month) Uwe Brauer
2019-08-19 12:29 ` Thomas Plass
2019-08-18 10:26 ` insert date-stamp for one month Ken Mankoff
2019-08-18 10:37 ` Uwe Brauer
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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).