From: Jean Louis <bugs@gnu.support>
To: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: How to get nicer localized date?
Date: Sun, 12 Jun 2022 20:34:24 +0300 [thread overview]
Message-ID: <courier.0000000062A623AB.000066C4@stw1.rcdrun.com> (raw)
I have been reading description of `format-time-string' but I cannot
find a way to get a nicer, readable, easier understandable, localized
date. I have to give an ISO 8601 date "2022-06-12" to a function and
to convert it automatically to the date in particular language, like
German, but without abbreviations and without time.
This function is attempt to do that:
;; Work in progress
(defun rcd-iso8601-date-to-locale-date (date locale)
"Convert ISO 8601 date to localized date."
(let* ((system-time-locale locale)
(date (format-time-string "%A %x" (float-time (date-to-time date))))
(place (string-match " ..:..:.." date))
(date (substring date 0 place)))
date))
However, I do not find the output here nice:
;; (rcd-iso8601-date-to-locale-date "2022-06-12" "en_US.UTF-8") ⇒ "Sun 12 Jun 2022"
As I would rather like the output to be "Sunday, June 12th 2022" or
similar, to be very readable.
;; (rcd-iso8601-date-to-locale-date "2022-06-12" "de_DE.UTF-8") ⇒ "So 12 Jun 2022"
Also the above one is not what I really want, I would like it as
"Sonntag, 12 Juni 2022"
I would like to have full name of week day and full name of the
month. And I cannot find solution in the current
`format-time-string'. Function shall be general so that it is switched
by locale string such as "de_DE.UTF-8".
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
next reply other threads:[~2022-06-12 17:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-12 17:34 Jean Louis [this message]
2022-06-13 3:15 ` How to get nicer localized date? Emanuel Berg
2022-06-13 7:54 ` How to get nicer localized date? [SOLVED] Jean Louis
2022-06-13 21:00 ` Emanuel Berg
2022-06-13 21:30 ` Emanuel Berg
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.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=courier.0000000062A623AB.000066C4@stw1.rcdrun.com \
--to=bugs@gnu.support \
--cc=help-gnu-emacs@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.
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).