* bug#46505: 27.1.91; Having a hard time manipulating a date
@ 2021-02-14 10:42 Damien Cassou
2022-06-17 14:05 ` Lars Ingebrigtsen
0 siblings, 1 reply; 2+ messages in thread
From: Damien Cassou @ 2021-02-14 10:42 UTC (permalink / raw)
To: 46505
Hi,
I'm finding it very hard to manipulate dates.
What I want:
Example input: "2021-01-20"
Corresponding expected output: "20 Jan 2021"
What I tried:
(format-time-string "%d %b %Y" (iso8601-parse "2021-01-20"))
⇒ invalid time specification
(format-time-string "%d %b %Y" (iso8601-parse "2021-01-20T00:00:00"))
⇒ "01 Jan 1970" ;; note the wrong year
What works:
(format-time-string
"%d %b %Y"
(encode-time (iso8601-parse "2021-01-20T00:00:00")))
⇒ "20 Jan 2021"
I found the Elisp manual confusing with all the date formats, all the
functions and their different kinds of arguments.
Possible improvements:
- make format-time-string accept as 2nd argument the return value of
(iso8601-parse "2021-01-20T00:00:00") with a correct year
- make format-time-string accept as 2nd argument the return value of
(iso8601-parse "2021-01-20") without sending an "invalid time
specification"
- restructure the manual to start with a page describing the different
time formats used throughout Emacs with a table listing all conversion
functions, the kind of input they take and the kind of output they
generate and examples for each.
In GNU Emacs 27.1.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.21, cairo version 1.16.0) Windowing system distributor 'Fedora
Project', version 11.0.12010000 System Description: Fedora 33
(Workstation Edition)
Best,
--
Damien Cassou
"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#46505: 27.1.91; Having a hard time manipulating a date
2021-02-14 10:42 bug#46505: 27.1.91; Having a hard time manipulating a date Damien Cassou
@ 2022-06-17 14:05 ` Lars Ingebrigtsen
0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-17 14:05 UTC (permalink / raw)
To: Damien Cassou; +Cc: 46505
Damien Cassou <damien@cassou.me> writes:
> Possible improvements:
>
> - make format-time-string accept as 2nd argument the return value of
> (iso8601-parse "2021-01-20T00:00:00") with a correct year
>
> - make format-time-string accept as 2nd argument the return value of
> (iso8601-parse "2021-01-20") without sending an "invalid time
> specification"
format-time-string takes Lisp timestamps as arguments, not decoded time
structures, and I don't think that could change -- the formats are
syntactically ambiguous.
> - restructure the manual to start with a page describing the different
> time formats used throughout Emacs with a table listing all conversion
> functions, the kind of input they take and the kind of output they
> generate and examples for each.
But I've now improved the documentation here to clarify which functions
take and return Lisp timestamps vs. decoded time structures.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-17 14:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-14 10:42 bug#46505: 27.1.91; Having a hard time manipulating a date Damien Cassou
2022-06-17 14:05 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.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).