From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: How to get nicer localized date? Date: Sun, 12 Jun 2022 20:34:24 +0300 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20721"; mail-complaints-to="usenet@ciao.gmane.io" To: Help GNU Emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 12 19:35:44 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o0RV2-0005Er-F2 for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 12 Jun 2022 19:35:44 +0200 Original-Received: from localhost ([::1]:34870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o0RV1-00025o-3w for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 12 Jun 2022 13:35:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o0RUW-00025a-SI for help-gnu-emacs@gnu.org; Sun, 12 Jun 2022 13:35:12 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:45143) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o0RUU-0000Vr-CP for help-gnu-emacs@gnu.org; Sun, 12 Jun 2022 13:35:12 -0400 Original-Received: from localhost ([::ffff:102.84.37.119]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000087C5F.0000000062A623AC.000066C4; Sun, 12 Jun 2022 10:34:35 -0700 Received-SPF: pass client-ip=217.170.207.13; envelope-from=support1@rcdrun.com; helo=stw1.rcdrun.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:137744 Archived-At: 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/