all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Damien Cassou <damien@cassou.me>
To: 46505@debbugs.gnu.org
Subject: bug#46505: 27.1.91; Having a hard time manipulating a date
Date: Sun, 14 Feb 2021 11:42:49 +0100	[thread overview]
Message-ID: <878s7rudzq.fsf@cassou.me> (raw)

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





             reply	other threads:[~2021-02-14 10:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-14 10:42 Damien Cassou [this message]
2022-06-17 14:05 ` bug#46505: 27.1.91; Having a hard time manipulating a date Lars Ingebrigtsen

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

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

  git send-email \
    --in-reply-to=878s7rudzq.fsf@cassou.me \
    --to=damien@cassou.me \
    --cc=46505@debbugs.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 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.