emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ascii-timestamps like 31.12.2021 to iso(org) format <2020-12-31> and back
@ 2021-12-31 13:21 Uwe Brauer
  2021-12-31 13:58 ` Eric S Fraga
  2022-01-04 10:00 ` Max Nikulin
  0 siblings, 2 replies; 5+ messages in thread
From: Uwe Brauer @ 2021-12-31 13:21 UTC (permalink / raw)
  To: emacs-orgmode


Hi

Does anybody know about a function that would convert between 
date format  like 31.12.2021 to  <2020-12-31> and back?

Thanks

Uwe Brauer 



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

* Re: ascii-timestamps like 31.12.2021 to iso(org) format <2020-12-31> and back
  2021-12-31 13:21 ascii-timestamps like 31.12.2021 to iso(org) format <2020-12-31> and back Uwe Brauer
@ 2021-12-31 13:58 ` Eric S Fraga
  2021-12-31 16:05   ` Uwe Brauer
  2022-01-04 10:00 ` Max Nikulin
  1 sibling, 1 reply; 5+ messages in thread
From: Eric S Fraga @ 2021-12-31 13:58 UTC (permalink / raw)
  To: emacs-orgmode

On Friday, 31 Dec 2021 at 14:21, Uwe Brauer wrote:
> ⚠️ Caution: External sender
>
>
> Hi
>
> Does anybody know about a function that would convert between
> date format  like 31.12.2021 to  <2020-12-31> and back?

This is Emacs, of course, so you could use query-replace-regexp (M-%)
with, for instance

\([0-9][0-9]\)\.\([0-9][0-9]\)\.\([0-9]\{4\}\)

as the pattern to search for and

<\3-\2-\1>

as the replacement.  The converse is left as an exercise for the
reader. ;-)

-- 
: Eric S Fraga, with org release_9.5.2-289-gce75d2 in Emacs 29.0.50
: Latest paper written in org: https://arxiv.org/abs/2106.05096


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

* Re: ascii-timestamps like 31.12.2021 to iso(org) format <2020-12-31> and back
  2021-12-31 13:58 ` Eric S Fraga
@ 2021-12-31 16:05   ` Uwe Brauer
  2021-12-31 16:40     ` Eric S Fraga
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Brauer @ 2021-12-31 16:05 UTC (permalink / raw)
  To: emacs-orgmode

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

>>> "ESF" == Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> On Friday, 31 Dec 2021 at 14:21, Uwe Brauer wrote:
>> ⚠️ Caution: External sender
>> 
>> 
>> Hi
>> 
>> Does anybody know about a function that would convert between
>> date format  like 31.12.2021 to  <2020-12-31> and back?

> This is Emacs, of course, so you could use query-replace-regexp (M-%)
> with, for instance

> \([0-9][0-9]\)\.\([0-9][0-9]\)\.\([0-9]\{4\}\)

> as the pattern to search for and

> <\3-\2-\1>

> as the replacement.  The converse is left as an exercise for the
> reader. ;-)

Thanks the \{4\} surprise me. I tried

(query-replace-regexp "\\(\\<[0-9]*\\)\\([\\.]\\)\\([0-9]*\\>\\)" "\\3\\2\\1")

And that did not work.

Uwe 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

* Re: ascii-timestamps like 31.12.2021 to iso(org) format <2020-12-31> and back
  2021-12-31 16:05   ` Uwe Brauer
@ 2021-12-31 16:40     ` Eric S Fraga
  0 siblings, 0 replies; 5+ messages in thread
From: Eric S Fraga @ 2021-12-31 16:40 UTC (permalink / raw)
  To: emacs-orgmode

On Friday, 31 Dec 2021 at 17:05, Uwe Brauer wrote:
> Thanks the \{4\} surprise me. I tried
>
> (query-replace-regexp "\\(\\<[0-9]*\\)\\([\\.]\\)\\([0-9]*\\>\\)" "\\3\\2\\1")

Not sure what this is trying to do.  If it's going from <2021-12-31> to 31.12.2021, you shouldn't escape the < or >, you are not matching the -, and there are only 2 number matches.  Maybe you want

<\\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\)>
to
\\3.\\2.\\1

?

-- 
: Eric S Fraga, with org release_9.5.2-289-gce75d2 in Emacs 29.0.50
: Latest paper written in org: https://arxiv.org/abs/2106.05096


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

* Re: ascii-timestamps like 31.12.2021 to iso(org) format <2020-12-31> and back
  2021-12-31 13:21 ascii-timestamps like 31.12.2021 to iso(org) format <2020-12-31> and back Uwe Brauer
  2021-12-31 13:58 ` Eric S Fraga
@ 2022-01-04 10:00 ` Max Nikulin
  1 sibling, 0 replies; 5+ messages in thread
From: Max Nikulin @ 2022-01-04 10:00 UTC (permalink / raw)
  To: emacs-orgmode

On 31/12/2021 20:21, Uwe Brauer wrote:
> 
> Does anybody know about a function that would convert between
> date format  like 31.12.2021 to  <2020-12-31> and back?

Uwe, I suggest you to create a feature request at 
https://debbugs.gnu.org for emacs to add a function similar to strptime 
that can parse date-time string accordingly to given format, see
info "(libc) Low-Level Time String Parsing" 
https://www.gnu.org/software/libc/manual/html_node/Low_002dLevel-Time-String-Parsing.html

Actually, I suppose, you need a function that parses date accordingly to 
current locale. It can be added to the feature request as well (and Eli 
will say that since Emacs is a multilingual editor, there is no well 
defined "current locale").



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

end of thread, other threads:[~2022-01-04 10:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-31 13:21 ascii-timestamps like 31.12.2021 to iso(org) format <2020-12-31> and back Uwe Brauer
2021-12-31 13:58 ` Eric S Fraga
2021-12-31 16:05   ` Uwe Brauer
2021-12-31 16:40     ` Eric S Fraga
2022-01-04 10:00 ` Max Nikulin

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