From: "Stefan Möding" <s.moeding@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: The wild and weird world of Emacs Lisp date/time arithmetic
Date: Thu, 17 Dec 2020 21:35:57 +0100 [thread overview]
Message-ID: <m2im90kw5u.fsf@athena.moeding.net> (raw)
In-Reply-To: <CANc-5UwfOWZd3=bVU-gHBu2CuYZqB3yDbfjfkirgimksB9dYdA@mail.gmail.com> (Skip Montanaro's message of "Thu, 17 Dec 2020 14:04:54 -0600")
Skip Montanaro <skip.montanaro@gmail.com> writes:
> Still, it seems there should be an inverse to parse-time-string which
> consumes a format string and one of those n-element lists. I'm thinking in
> terms of C stdio functions strptime and strftime, or the methods of the
> same name for Python's datetime objects. That's what fooled me about the
> format-time-string function. Its name implies that it would consume the
> output of parse-time-string but it doesn't.
`format-time-string’ seems to use Lisp timestamps which can be created
with `encode-time’. The following seems to solve your initial problem:
(format-time-string
"%Y-%m-%d"
(encode-time (decoded-time-add (parse-time-string "2020-05-17")
(make-decoded-time :day 1))))
Yes, it probably should be easier to do...
--
Stefan
next prev parent reply other threads:[~2020-12-17 20:35 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
2020-12-17 20:04 ` Skip Montanaro
2020-12-17 20:35 ` Stefan Möding [this message]
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=m2im90kw5u.fsf@athena.moeding.net \
--to=s.moeding@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).