unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Eduardo Ochs <eduardoochs@gmail.com>
Cc: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: SOLVED - Re: Is there function to get day name from the date?
Date: Thu, 2 Jan 2025 16:23:47 +0300	[thread overview]
Message-ID: <Z3aTY5zjiGSRDn0k@lco2> (raw)
In-Reply-To: <CADs++6haLX16rDmtzjaX8oRXXm0sFpfNep2fpW9h6xJyAEQwqQ@mail.gmail.com>

* 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



      reply	other threads:[~2025-01-02 13:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Jean Louis [this message]

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=Z3aTY5zjiGSRDn0k@lco2 \
    --to=bugs@gnu.support \
    --cc=eduardoochs@gmail.com \
    --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).