From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Teemu Likonen Newsgroups: gmane.emacs.help Subject: Re: The wild and weird world of Emacs Lisp date/time arithmetic Date: Thu, 17 Dec 2020 21:47:27 +0200 Message-ID: <87eejo1agg.fsf@iki.fi> References: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40213"; mail-complaints-to="usenet@ciao.gmane.io" To: Skip Montanaro , Help GNU Emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 17 20:50:20 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 1kpzI3-000AIT-7L for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Dec 2020 20:50:19 +0100 Original-Received: from localhost ([::1]:40920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpzI2-0002zE-1X for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Dec 2020 14:50:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpzFk-0002xd-7B for help-gnu-emacs@gnu.org; Thu, 17 Dec 2020 14:47:56 -0500 Original-Received: from meesny.iki.fi ([195.140.195.201]:46400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpzFb-000142-Vo for help-gnu-emacs@gnu.org; Thu, 17 Dec 2020 14:47:55 -0500 Original-Received: from mithlond (mobile-access-bceecc-211.dhcp.inet.fi [188.238.204.211]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: tlikonen) by meesny.iki.fi (Postfix) with ESMTPSA id 4C1C620230; Thu, 17 Dec 2020 21:47:34 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1608234454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Dzr6IttznVY+bnzA+cS6DLaIM+5U7K4WUTlPB3wTL7M=; b=DlxTaduihw1AlpyQT8ul0s90mYLGfUnEjdTijR4Vav8yLKpGoCIIZJdNiDC8cl81xddK7l AsdBsp35zyH5jAY5hIl/pYAPYZ1QYBSkN3f5KyXZZmfzRVmJovwfKFIdXkQDmaNJtUTXd/ dnBgy4xG7qq63UK3GFkra53UzrZQOVc= In-Reply-To: ARC-Seal: i=1; s=meesny; d=iki.fi; t=1608234454; a=rsa-sha256; cv=none; b=EzT8mE+15euL6+/JDjUHWeHZcG7jlSNpyxAA2zWc2h2x36i/35AKUi9/VcHk/OmB5Ku1XE jC1WuO8fpqFKju9SSZumH6jdkZM24C57zgluRneVR04w5ywJND7UIzeU60QlupA+9dTL0s 2YqD+tROOLhQJkdVVY7QxSvtoESaneM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1608234454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Dzr6IttznVY+bnzA+cS6DLaIM+5U7K4WUTlPB3wTL7M=; b=xBh0/dDDrIdKmPa4eu/s1YC14WZ6gvFI9AolqE0Sa9YhVlRDd1HCILUT+JntBTMZsvrVoy dsLykveclAZTzEExaSQar+/+1Hc+qzRHdkuhws1fUIBtSSPZvoNTyo/rCVO8lRrK3ERQVU T4eQ+EtFVxHBSmXWOELfK2oIXISYOls= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=tlikonen smtp.mailfrom=tlikonen@iki.fi Received-SPF: pass client-ip=195.140.195.201; envelope-from=tlikonen@iki.fi; helo=meesny.iki.fi 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, 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:126468 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable * 2020-12-17 09:57:18-06, Skip Montanaro wrote: > I want to write a function to add a day [...] > I have no problem plucking the time out of the buffer or decoding the > string. I'm having trouble converting back to string form after > parsing and doing the arithmetic. You can do it with a function like this: (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)))) (my-add-one-day "2020-12-31") ;=3D> "2021-01-01" =2D-=20 /// Teemu Likonen - .-.. https://www.iki.fi/tlikonen/ // OpenPGP: 4E1055DC84E9DFF613D78557719D69D324539450 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iIYEARYIAC4WIQTJW2wqtelxC1gHdbitnXWr7pTCcwUCX9u1zxAcdGxpa29uZW5A aWtpLmZpAAoJEK2ddavulMJzka4A/1AtG+cIEza4CJ2WjiuBE9GcLtC1A/Vzkf1G hSNYb5EpAQC7/VcoJFupkn6vENy22Dwa8dCJkNicGZDM0Z8ENqWxDg== =p/of -----END PGP SIGNATURE----- --=-=-=--