unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to get nicer localized date?
@ 2022-06-12 17:34 Jean Louis
  2022-06-13  3:15 ` Emanuel Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Jean Louis @ 2022-06-12 17:34 UTC (permalink / raw)
  To: Help GNU Emacs

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/



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

end of thread, other threads:[~2022-06-13 21:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-12 17:34 How to get nicer localized date? Jean Louis
2022-06-13  3:15 ` 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

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