* Is there function to get day name from the date?
@ 2025-01-02 10:34 Jean Louis
2025-01-02 12:44 ` Eduardo Ochs
0 siblings, 1 reply; 3+ messages in thread
From: Jean Louis @ 2025-01-02 10:34 UTC (permalink / raw)
To: Help GNU Emacs
Is there maybe native Emacs Lisp function that can give me the name of
the day from the date?
In PostgreSQL I can do this:
SELECT to_char('2025-01-02'::date, 'Day');
to_char
-----------
Thursday
(1 row)
Maybe Emacs has something like this built-in?
Jean Louis
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Is there function to get day name from the date?
2025-01-02 10:34 Is there function to get day name from the date? Jean Louis
@ 2025-01-02 12:44 ` Eduardo Ochs
2025-01-02 13:23 ` SOLVED - " Jean Louis
0 siblings, 1 reply; 3+ messages in thread
From: Eduardo Ochs @ 2025-01-02 12:44 UTC (permalink / raw)
To: Jean Louis; +Cc: Help GNU Emacs
On Thu, 2 Jan 2025 at 07:35, Jean Louis <bugs@gnu.support> wrote:
>
> Is there maybe native Emacs Lisp function that can give me the name of
> the day from the date?
>
> In PostgreSQL I can do this:
>
> SELECT to_char('2025-01-02'::date, 'Day');
>
> to_char
> -----------
> Thursday
> (1 row)
>
>
> Maybe Emacs has something like this built-in?
>
> Jean Louis
Please try this,
(format-time-string "%A %a %u %w")
(format-time-string "%A %a %u %w" (parse-time-string "2024-12-28 12:00"))
(format-time-string "%A %a %u %w" (parse-time-string "2024-12-27 12:00"))
fix the bug, and send the fixed version to the list!
Cheers =),
Eduardo
^ permalink raw reply [flat|nested] 3+ messages in thread
* SOLVED - Re: Is there function to get day name from the date?
2025-01-02 12:44 ` Eduardo Ochs
@ 2025-01-02 13:23 ` Jean Louis
0 siblings, 0 replies; 3+ messages in thread
From: Jean Louis @ 2025-01-02 13:23 UTC (permalink / raw)
To: Eduardo Ochs; +Cc: Help GNU Emacs
* Eduardo Ochs <eduardoochs@gmail.com> [2025-01-02 15:45]:
> Please try this,
>
> (format-time-string "%A %a %u %w") ➜ "Thursday Thu 4 4"
> (format-time-string "%A %a %u %w" (parse-time-string "2024-12-28 12:00")) ➜ "Thursday Thu 4 4"
> (format-time-string "%A %a %u %w" (parse-time-string "2024-12-27 12:00")) ➜ "Thursday Thu 4 4"
>
> fix the bug, and send the fixed version to the list!
;; Parse the date string using date-to-time
(defun parse-date-string (date-string)
(date-to-time date-string))
;; Format the parsed time
(defun format-date-string (format-string date-string)
(format-time-string format-string (parse-date-string date-string)))
;; Test the functions
(format-date-string "%A %a %u %w" "2024-12-28 12:00") ➜ "Saturday Sat 6 6"
(format-date-string "%A %a %u %w" "2024-12-27 12:00") ➜ "Friday Fri 5 5"
(format-date-string "%A" "2025-12-27 12:00") ➜ "Friday"
(format-date-string "%A" "2025-01-02 12:00") ➜ "Thursday"
(format-date-string "%A" "2025-01-02 11:59") ➜ "Thursday"
(format-date-string "%A" "2025-01-02 00:00") ➜ "Thursday"
I got it.
--
Jean Louis
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-02 13:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-02 10:34 Is there function to get day name from the date? Jean Louis
2025-01-02 12:44 ` Eduardo Ochs
2025-01-02 13:23 ` SOLVED - " Jean Louis
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).