From: Teemu Likonen <tlikonen@iki.fi>
To: Skip Montanaro <skip.montanaro@gmail.com>,
Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: Re: The wild and weird world of Emacs Lisp date/time arithmetic
Date: Thu, 17 Dec 2020 21:59:57 +0200 [thread overview]
Message-ID: <87bles19vm.fsf@iki.fi> (raw)
In-Reply-To: <87eejo1agg.fsf@iki.fi>
[-- Attachment #1: Type: text/plain, Size: 979 bytes --]
* 2020-12-17 21:47:27+02, Teemu Likonen wrote:
> (defun my-add-one-day (date-string)
> (let ((decoded (decoded-time-add (parse-time-string date-string)
> (make-decoded-time :day 1))))
> (format "%04d-%02d-%02d"
> (nth 5 decoded)
> (nth 4 decoded)
> (nth 3 decoded))))
It's probably better to use access functions DECODED-TIME-YEAR etc.
instead of accessing list elements with NTH. So:
(defun my-add-one-day (date-string)
(let ((decoded (decoded-time-add (parse-time-string date-string)
(make-decoded-time :day 1))))
(format "%04d-%02d-%02d"
(decoded-time-year decoded)
(decoded-time-month decoded)
(decoded-time-day decoded))))
--
/// Teemu Likonen - .-.. https://www.iki.fi/tlikonen/
// OpenPGP: 4E1055DC84E9DFF613D78557719D69D324539450
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 251 bytes --]
next prev parent reply other threads:[~2020-12-17 19:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-17 15:57 The wild and weird world of Emacs Lisp date/time arithmetic Skip Montanaro
2020-12-17 19:23 ` Christopher Dimech
2020-12-17 19:47 ` Teemu Likonen
2020-12-17 19:59 ` Teemu Likonen [this message]
2020-12-17 20:04 ` Skip Montanaro
2020-12-17 20:35 ` Stefan Möding
2020-12-17 20:51 ` Skip Montanaro
2020-12-18 15:37 ` Emanuel Berg via Users list for the GNU Emacs text editor
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=87bles19vm.fsf@iki.fi \
--to=tlikonen@iki.fi \
--cc=help-gnu-emacs@gnu.org \
--cc=skip.montanaro@gmail.com \
/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).