emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Orm Finnendahl <orm.finnendahl@selma.hfmdk-frankfurt.de>
To: emacs-orgmode@gnu.org
Subject: custom time format extension
Date: Wed, 29 Jul 2020 22:16:34 +0200	[thread overview]
Message-ID: <20200729201634.GA813784@t480s-orm.localdomain> (raw)

Hi,

 when exporting timestamps it always bothered me that timestamps with
start and end time on the same day got exported with a full date for
the start and end times separated by a dash.

After thinking about this for some time I implemented a method today,
which combines the advantage of being utmost flexible while
maintaining full backwards compatibility.

This is how it works: The cdr of org-time-stamp-custom-formats
normally contains a format string for formatting timestamps with
start/end time. When supplying a list of three strings instead of the
single format string to the cdr of org-time-stamp-custom-formats, the
first, second and third elements of that list are interpreted as
follows:

The first element is the full format in case start and end of the
timestamp are not on the same day. The second element of the list is
the format string for the start time of the timestamp. The third
element of the list is a format string for the end time of the
timestamp. (BTW: Supplying a list as second element of a dotted list
is equivalent to supplying a list with four strings to
org-time-stamp-custom-formats)

Below the mail is a short example for german date strings.

In case somebody is interested, I can provide the code off list. If
any of the maintainers is reading on this list and thinks it should
get revised and maybe adopted for orgmode, please let me know how to
issue pull requests for the code. I tried to be minimally invasive ;-)

--
Orm

-----------
Example:

(org-time-stamp-custom-formats '("%a %d.%m.%Y" . ("%a %d.%m.%Y %H:%M Uhr"
                                                  "%a %d.%m.%Y %H:%M"
                                                  "%H:%M Uhr")))

Formatting

<2020-11-21 Sa>  -> Sa 21.11.2020

<2020-11-21 Sa 10:00-18:00>  -> Sa 21.11.2020 10:00--18:00 Uhr


<2020-11-21 Sa 10:00>--<2020-11-22 So 18:00> -> Sa 21.11.2020 10:00 Uhr--So 22.11.2020 18:00 Uhr


             reply	other threads:[~2020-07-29 20:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-29 20:16 Orm Finnendahl [this message]
2020-07-30  7:25 ` custom time format extension Orm Finnendahl

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200729201634.GA813784@t480s-orm.localdomain \
    --to=orm.finnendahl@selma.hfmdk-frankfurt.de \
    --cc=emacs-orgmode@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 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).