From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id SLGzEY1jYGJxMwAAbAwnHQ (envelope-from ) for ; Wed, 20 Apr 2022 21:48:29 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 5ZS9EY1jYGJ5XwAA9RJhRA (envelope-from ) for ; Wed, 20 Apr 2022 21:48:29 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 03AF43C7AF for ; Wed, 20 Apr 2022 21:48:28 +0200 (CEST) Received: from localhost ([::1]:47136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhGJP-0006Hj-3X for larch@yhetil.org; Wed, 20 Apr 2022 15:48:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhFpq-00034L-EH for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 15:17:54 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:56202) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhFpn-0003LP-7C for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 15:17:53 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2BCAA1600CC; Wed, 20 Apr 2022 12:17:49 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id yjIJWa97D4hA; Wed, 20 Apr 2022 12:17:48 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1C5561600D9; Wed, 20 Apr 2022 12:17:48 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 23io3Q-7kAZr; Wed, 20 Apr 2022 12:17:48 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E47951600CC; Wed, 20 Apr 2022 12:17:47 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------s60V0Pd46BU99QesSH0ZmI3j" Message-ID: <37ffb641-a4da-89fd-6ef5-909db5a5fe3c@cs.ucla.edu> Date: Wed, 20 Apr 2022 12:17:47 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US To: Max Nikulin References: <5ed963b2-3fa8-48d8-627e-bc0571d15b43@gmail.com> <149de00f-115b-5367-414f-c7700ef8966b@cs.ucla.edu> <2d57e59b-f971-483b-ad65-e0c5ff7883e8@gmail.com> <3624beb8-71fd-924e-a065-74d0034ed351@cs.ucla.edu> <8ba9e258-dd24-a0a0-1aa6-9c2831c05af0@gmail.com> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: bug#54764: encode-time: make DST and TIMEZONE fields of the list argument optional ones In-Reply-To: <8ba9e258-dd24-a0a0-1aa6-9c2831c05af0@gmail.com> Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@cs.ucla.edu; helo=zimbra.cs.ucla.edu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: orgmode , 54764@debbugs.gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650484108; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=iPdEW+X3jyVBQrwB1yJvet7XXmvonkpYs1L3bGxy+9Q=; b=VZukWrAd26loclgGDdKMJtZREZs3nHLJtvTd2BuVqjME/opZaB4DM/fklMW1mIYnJGLnxO EN3ONtCr7+mqCA+pUHQmKqC494AsFRHb5xzWtVMFCjvRwqT3HpHj+RUrqijEeOGpoYO23f ySDTCQt2K9waHzciDWN6zOuSqZnmyQ6KXcg5ng+sMuYiqYDLp/zAhx+zpY5rpkXnB/c3Mj UsOlO/p69PrPhl2KkuTV6nZIf3UrgpmnHkKzkN+R59Tcfqbet7BE+fY+LXxP3uFlUdyb1H ff8oxP9YO7VJ1FRm0jq5tqjMEwbpKJ5n4Ua2lPl2JVT2VAWHwchvGeh+2AI/0g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650484108; a=rsa-sha256; cv=none; b=r6h0B0TXQmpxeAHPGveVu2XygA75fNYQd5rrXeO6RfU/iunVNrYRb/lWdEjRlqfv0fsQip v8D/PFbocPJ7mAlvBHKE0IpubP9sWVaKZwFZSKK+pjphI27dFGfSBWyNPOLVJALKvyUhOc fxtrTSslc3HO7MTLsoDOyWTQK4hZPtjWlDa8Cujs60F/8bsWcZAAqJQ9LoHe4xVjGhnsHr YqG1I4ocnGWX1LMpE7IqauOjqnD4ntCO05JUfEhs722JN6ugmThhVWk2nTHDeEn6zf2bhF Y1tqm0WS7VtjGkqCkb3FhmjfVvTqTkH8ZLOwPGeIr4OpxvH3YgxwjrAMquuRFQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.04 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 03AF43C7AF X-Spam-Score: -3.04 X-Migadu-Scanner: scn0.migadu.com X-TUID: X1PwE96/a5yE This is a multi-part message in MIME format. --------------s60V0Pd46BU99QesSH0ZmI3j Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable On 4/20/22 09:56, Max Nikulin wrote: > A typo: double "a". Thanks, fixed in the attached which I installed in master. > If I get your idea correctly then "January, 31" + "1 month" should be=20 > more impressive as impossible date. Thanks, good idea; also in the attached patch. > I can not figure out which elisp function can help to=20 > determine wall time for Aug 1 start of day in Cairo: >=20 > Africa/Cairo=C2=A0 Thu Jul 31 21:59:59 2014 UT =3D Thu Jul 31 23:59:59 = 2014 EET=20 > isdst=3D0 gmtoff=3D7200 > Africa/Cairo=C2=A0 Thu Jul 31 22:00:00 2014 UT =3D Fri Aug=C2=A0 1 01:0= 0:00 2014=20 > EEST isdst=3D1 gmtoff=3D10800 >=20 > input: 2014-08-01 Africa/Cairo > (timezone may be implicit as the system one) > expected output: 01:00:00 Given mktime's limitations there's no trivial way to do this for=20 arbitrary timestamps, since 00:00 doesn't exist in Cairo that day.=20 Worse, in some locations near the International Date Line entire days do=20 not exist, because at 00:00 they advanced the clocks forward 24 hours in=20 order to move the date line. It sounds like you're asking for a function that, given a date, yields=20 the first broken-down timestamp on or after 00:00 of that date. For=20 something like that, I'd use encode-time on 00:00 of that date to get a=20 timestamp T, and then use time-add and decode-time to decode T-86400=20 seconds, T, and T+86400 seconds, and if the decoded times all look fine=20 then return (decode-time T). If not (i.e., their UTC offsets differ, or=20 T's decoded time is not 00:00 on the correct date) I'd use binary search=20 to find discontinuities between T-86400 and T+86400 and look next to=20 those discontinuities to find timestamps closer to what you want. Of course this is not ideal - but it's similar to what many mktime=20 implementations do internally, and it's also similar to what Emacs's=20 cal-dst already does (maybe you can look there for ideas), so you'd be=20 in good company. --------------s60V0Pd46BU99QesSH0ZmI3j Content-Type: text/x-patch; charset=UTF-8; name="0001-More-encode-time-pitfall-doc-fixes.patch" Content-Disposition: attachment; filename="0001-More-encode-time-pitfall-doc-fixes.patch" Content-Transfer-Encoding: base64 RnJvbSBmOThjM2Y0NDI2ZmVjZjc5NGY0N2YyN2FlYmUxZjNiODU0ZmIxYmZkIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8ZWdnZXJ0QGNzLnVjbGEuZWR1 PgpEYXRlOiBXZWQsIDIwIEFwciAyMDIyIDEyOjAzOjE5IC0wNzAwClN1YmplY3Q6IFtQQVRD SF0gTW9yZSBlbmNvZGUtdGltZSBwaXRmYWxsIGRvYyBmaXhlcwoKKiBkb2MvbGlzcHJlZi9v cy50ZXhpIChUaW1lIENvbnZlcnNpb24pOiBJbXByb3ZlIGRpc2N1c3Npb24gb2YKZW5jb2Rl LXRpbWUgcGl0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