help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to get nicer localized date?


From: Jean Louis
Subject: How to get nicer localized date?
Date: Sun, 12 Jun 2022 20:34:24 +0300

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/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]