From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Stefan_M=C3=B6ding?= Newsgroups: gmane.emacs.help Subject: Re: The wild and weird world of Emacs Lisp date/time arithmetic Date: Thu, 17 Dec 2020 21:35:57 +0100 Message-ID: References: <87eejo1agg.fsf@iki.fi> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11528"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 17 21:37:26 2020 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 1kq01e-0002tt-60 for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Dec 2020 21:37:26 +0100 Original-Received: from localhost ([::1]:57982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kq01d-0007lR-3J for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Dec 2020 15:37:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kq00K-0007Ge-Hm for help-gnu-emacs@gnu.org; Thu, 17 Dec 2020 15:36:04 -0500 Original-Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:46491) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kq00J-0007Dp-3J for help-gnu-emacs@gnu.org; Thu, 17 Dec 2020 15:36:04 -0500 Original-Received: by mail-wr1-x42c.google.com with SMTP id d13so9672014wrc.13 for ; Thu, 17 Dec 2020 12:36:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-transfer-encoding; bh=EQCT4B1fzNReiV7hhpVen1WDjadsVeigkbvn2wV2Hgk=; b=fjnZ1B8tgrlPjGHcFpyalrMe664aAV9+4cpYlwnkWocuOG4Edv56xaizmkBy07XOXM 0WHq3S/eaVT/cyWWndcFzJWiSQd5JPCPnAh/l8kXPRDtMJoLijEH0v7CdaBNXrqXvS2g R7+v5rbCOtRRzhngX8U6U8TsXN2569HLIeq+CcLMkYMZxUcG1m8LxOvau8TnEQglnb9y weRgqq2rXlHnr47mWOXn6EGPOH2O7RTGkin/N8sZ1FLqnazgFo22xrd7CpJVgfw9ya1a mVC774YGEHejo8qrzcrsh6tPnyCpnAdcOeLv7RSXtg11rn+x/Mok1xpSnETrBYga3Wzp IaBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-transfer-encoding; bh=EQCT4B1fzNReiV7hhpVen1WDjadsVeigkbvn2wV2Hgk=; b=j673o2Bwdxh4crYqgk7ZYRSn+M16SbvFOBaYEWeJ+tdtIHag13ZpDM1AcWRWCuuqK3 /gyURec7Gosp4jf0pn2ir0cdAcl2mQOnWN+KYFjIUKCY2wZeMxHoE8945oOR/vtBh6O0 mj44FFt8NXrSATacAzNTyIXzP6sXEHwtvFgapwSkEOveOxFuTV4U8LEoS1YEclC16HcG MDcg3E1epOppEVJYdnyK9E/385ES6wWdvGVAoJV/IS2QxMPekS5J6R8R1fvPYzyqzEPe WX1A+xM/7ZSwXF6peGLghZYDnrloh+gAsbpIjM8Bs3CF7k1ZTe6Fcj0ANTv13CoDJVmp Rv7w== X-Gm-Message-State: AOAM530fTRKWRchoDVWIZNlOV5/Pza//2oqRf0tivvVVYgsrFP1l8oSQ 1bj4iKoPTmbwamUxXGk1Abcf4jr/q3w= X-Google-Smtp-Source: ABdhPJxNF86Io+V9B0VDjfoTjaWLVlceH092M9mjAvweI5Ht1BH/2AJdd9wcZNTmCV6Va9tSN7PRSA== X-Received: by 2002:a5d:44c6:: with SMTP id z6mr637068wrr.306.1608237359240; Thu, 17 Dec 2020 12:35:59 -0800 (PST) Original-Received: from athena.moeding.net (ip-176-199-80-138.hsi06.unitymediagroup.de. [176.199.80.138]) by smtp.gmail.com with ESMTPSA id h16sm10459896wrq.29.2020.12.17.12.35.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 12:35:58 -0800 (PST) In-Reply-To: (Skip Montanaro's message of "Thu, 17 Dec 2020 14:04:54 -0600") Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=s.moeding@gmail.com; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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:126472 Archived-At: Skip Montanaro 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=E2=80=99 seems to use Lisp timestamps which can be crea= ted with `encode-time=E2=80=99. The following seems to solve your initial prob= lem: (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... --=20 Stefan