From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id sB3tMBs2ZWKWxgAAbAwnHQ (envelope-from ) for ; Sun, 24 Apr 2022 13:35:55 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id EE4MMRs2ZWIOfAAA9RJhRA (envelope-from ) for ; Sun, 24 Apr 2022 13:35:55 +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 6041267D8 for ; Sun, 24 Apr 2022 13:35:55 +0200 (CEST) Received: from localhost ([::1]:33584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1niaWw-0003Mp-G4 for larch@yhetil.org; Sun, 24 Apr 2022 07:35:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1niaVw-0003Mb-7I for emacs-orgmode@gnu.org; Sun, 24 Apr 2022 07:34:52 -0400 Received: from ciao.gmane.io ([116.202.254.214]:41336) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1niaVt-0004N8-PE for emacs-orgmode@gnu.org; Sun, 24 Apr 2022 07:34:51 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1niaVq-0000FK-RO for emacs-orgmode@gnu.org; Sun, 24 Apr 2022 13:34:46 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: Re: [DRAFT][PATCH v2] org-encode-time compatibility and convenience helper Date: Sun, 24 Apr 2022 18:34:40 +0700 Message-ID: References: <7f4ea652-7d22-fb61-f873-5e92f078c9e6@gmail.com> <87mtgcmckj.fsf@localhost> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------Iz3eYep8zRry2Hp1Vfj9thTo" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US In-Reply-To: <87mtgcmckj.fsf@localhost> Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 28 X-Spam_score: 2.8 X-Spam_bar: ++ X-Spam_report: (2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.001, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , 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=1650800155; h=from:from:sender:sender: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=ixqzowUydMXSbmr5wRGE3HgB68MZox/9gGDNHCf56pc=; b=twVLm4mH2mG9YvPLOnrw2p3RXoFv/LBpAeiuia3WqrVTp2LSfT70YpZaptQJkebFTXLYCz mnfVWhxhPkrtxvjw9dMrE/FSJSIDQ0wMEKemwVEEGz3nnGxzGtVCnhogKvfQbet+xIBIcL vB+4cL6uI2YNKgt3fzytjqM3mgSDyv+ysLZW9cQln1I04GsNb42T19m9tUm1cz54vbDF4u ICj9tw4ISzuLWuqwyDnZAvBjPhN8AsmdRJlJHrZmv/djzaTHbODOg/R0BYFEa/C3X3tVpu Fzx780wNWBTnOj8VS0m9Jvd/2tp8E78lKdmEC1P70anrowqex5OeVppoukxsUg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650800155; a=rsa-sha256; cv=none; b=de5GrLeJZQaKiFtXTEYNU6KdcN/elAOb4mjbM/1KI9Ct9tVPMd6vmC+ZtsPkRnCGFaZjsW DIEIFcaNZ7mPijesfyfpwo5++nf9/ijypBwpnpHZno+Qp8yhYeZioPsd4RDMgaAgoBihpn HnuRxc4Xflt892u3nX+yIF/x2RKC6hqAwMgMf4yuPY19xyjH4CM/e/x5YXVyrzlJMr2QvM 0x36iIHi5ixW11DXcrIaRXzDaFd4eTtC2QeFOOFhAnpHjVuUIFH40qcInAPyxjOoWuhc6a IDmcZ+PvIq00SSPHwBqOGuj7ilBhxPHweDRSBZKrZfmw86a9IPPBWpDK+t2KUw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=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.78 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=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: 6041267D8 X-Spam-Score: 3.78 X-Migadu-Scanner: scn1.migadu.com X-TUID: 8hqr8HvD2YeN This is a multi-part message in MIME format. --------------Iz3eYep8zRry2Hp1Vfj9thTo Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 23/04/2022 15:25, Ihor Radchenko wrote: > Max Nikulin writes: > >> My patch requires more changes since the macro is just defined but not >> actually used. It does not fix the problem with "no DST" flag returned >> by some function in Org. I can prepare next patches, but I think it >> should be decided at first which approach should be accepted by Org Mode: >> - org-encode-time accepting both list or separate arguments >> - mix of `encode-time' with multiple arguments and org-encode-time-1 for >> lists. > > This whole timezone staff is complex. I got lost in the emacs devel > discussion half-way through. From point of view of API, I would prefer a > single function with docstring explaining the necessary caveats. To have namely a single function that accepts both a list or multiple arguments, it is necessary to introduce a new name to Emacs. `encode-time' has a subtle difference in behavior depending on the calling style and fixing this issue may break some code. That is why I decided to offer a macro. I have not figured out which kind of high-level API I would like to have instead of `encode-time', and I believe, it is acceptable to rely on default normalization and ambiguity resolution as the status quo. Problems may happen during 2 days of 365 and people usually expect some glitches for these days. There are too many caveats to explain them in docstring. >> + (if (cdr time) >> + `(encode-time ,@time) >> + `(apply #'encode-time ,(car time)))) > > Do I miss something or can you instead just do `(encode-time ,@time) > without if? I changed the code to use ,@time in both cases. Previous time likely I forgot to re-evaluate some definition, got some unexpected error, and decided to use `car' for a while. `if' can not be dropped however. In the case of (org-encode-time '(0 0 23 30 04 2022 nil nil nil)) `(encode-time ,@time) will be expanded to (encode-time (list 0 0 23 30 04 2022 nil nil nil)) due to (&rest time) argument. Single list argument is unsupported in Emacs-26. So `apply' cat not be avoided. >> + (should (string-equal >> + "2022-03-24 23:30:01" >> + (format-time-string >> + "%F %T" >> + (org-encode-time '(01 30 23 24 03 2022 nil -1 nil))))) >> ... > > These tests will be executed using system value of TZ. I am not sure if > tests are not going to break, say, in southern hemisphere or at some > other bizzare values of TZ. You are right, it is safer to run this test with explicitly chosen TZ value. I do not think there is a point in speculation whether the test fails in some currently existing time zone. I am attaching an updated version of the draft. I have added a macro for testing of particular time zones. --------------Iz3eYep8zRry2Hp1Vfj9thTo Content-Type: text/x-patch; charset=UTF-8; name="0001-org-macs.el-Introduce-a-helper-for-encode-time.patch" Content-Disposition: attachment; filename*0="0001-org-macs.el-Introduce-a-helper-for-encode-time.patch" Content-Transfer-Encoding: base64 RnJvbSA4ZmRjY2EzZjNiMGNmM2U4OTAxNDllYjc5ZWE2Yzc5NzBiN2QyY2ZhIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBNYXggTmlrdWxpbiA8bWFuaWt1bGluQGdtYWlsLmNv bT4KRGF0ZTogRnJpLCA4IEFwciAyMDIyIDIzOjEwOjUwICswNzAwClN1YmplY3Q6IFtQQVRD SF0gb3JnLW1hY3MuZWw6IEludHJvZHVjZSBhIGhlbHBlciBmb3IgYGVuY29kZS10aW1lJwoK KiBsaXNwL29yZy1tYWNzLmVsIChvcmctZW5jb2RlLXRpbWUpOiBOZXcgY29tcGF0aWJpbGl0 eSBhbmQgY29udmVuaWVuY2UKaGVscGVyIG1hY3JvIHRvIGFsbG93IGEgbGlzdCBmb3IgdGlt ZSBjb21wb25lbnRzIG9yIHNlcGFyYXRlIGFyZ3VtZW50cwppbmRlcGVuZGVudGx5IG9mIEVt YWNzIHZlcnNpb24uCiogdGVzdGluZy9saXNwL3Rlc3Qtb3JnLmVsIChvcmctdGVzdC13aXRo LXRpbWV6b25lKTogTmV3IG1hY3JvIHRvIGVuc3VyZQp0aGF0IHNvbWUgY29kZSBpcyBleGVj dXRlZCB3aXRoIG9yIHdpdGhvdXQgZGF5bGlnaHQgc2F2aW5nIHRpbWUgb3Igb3RoZXIKdGlt ZSBzaGlm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UgKCkKKyAgIlRlc3QgdmFyaW91cyB3YXlzIHRvIGNhbGwgYG9y Zy1lbmNvZGUtdGltZSciCisgIChvcmctdGVzdC13aXRoLXRpbWV6b25lICJVVEMiCisgICAg OzsgbGlzdCBhcyB0aGUgc29sZSBhcmd1bWVudAorICAgIChzaG91bGQgKHN0cmluZy1lcXVh bAorICAgICAgICAgICAgICIyMDIyLTAzLTI0IDIzOjMwOjAxIgorICAgICAgICAgICAgIChm b3JtYXQtdGltZS1zdHJpbmcKKyAgICAgICAgICAgICAgIiVGICVUIgorICAgICAgICAgICAg ICAob3JnLWVuY29kZS10aW1lICcoMSAzMCAyMyAyNCAzIDIwMjIgbmlsIC0xIG5pbCkpKSkp CisgICAgOzsgU0VDT05ELi4uWUVBUgorICAgIChzaG91bGQgKHN0cmluZy1lcXVhbAorICAg ICAgICAgICAgICIyMDIyLTAzLTI0IDIzOjMwOjAyIgorICAgICAgICAgICAgIChmb3JtYXQt dGltZS1zdHJpbmcKKyAgICAgICAgICAgICAgIiVGICVUIgorICAgICAgICAgICAgICAob3Jn LWVuY29kZS10aW1lIDIgMzAgMjMgMjQgMyAyMDIyKSkpKQorICAgIDs7IFNFQ09ORC4uLllF QVIgSUdOT1JFRCBEU1QgWk9ORQorICAgIChzaG91bGQgKHN0cmluZy1lcXVhbAorICAgICAg ICAgICAgICIyMDIyLTAzLTI0IDIzOjMwOjAzIgorICAgICAgICAgICAgIChmb3JtYXQtdGlt ZS1zdHJpbmcKKyAgICAgICAgICAgICAgIiVGICVUIgorICAgICAgICAgICAgICAob3JnLWVu Y29kZS10aW1lIDMgMzAgMjMgMjQgMyAyMDIyIG5pbCAtMSBuaWwpKSkpCisgICAgOzsgZnVu Y3Rpb24gY2FsbAorICAgIChzaG91bGQgKHN0cmluZy1lcXVhbAorICAgICAgICAgICAgICIy MDIyLTAzLTI0IDIzOjMwOjA0IgorICAgICAgICAgICAgIChmb3JtYXQtdGltZS1zdHJpbmcK KyAgICAgICAgICAgICAgIiVGICVUIgorICAgICAgICAgICAgICAob3JnLWVuY29kZS10aW1l IChhcHBseSAjJ2xpc3QgNCAzMCAyMyAnKDI0IDMgMjAyMiBuaWwgLTEgbmlsKSkpKSkpCisg ICAgOzsgd3JvbmcgbnVtYmVyIG9mIGFyZ3VtZW50cworICAgIChpZiAobm90ICh2ZXJzaW9u PCBlbWFjcy12ZXJzaW9uICIyNy4xIikpCisgICAgICAgIChzaG91bGQtZXJyb3IgKHN0cmlu Zy1lcXVhbAorICAgICAgICAgICAgICAgICAgICAgICAiMjAyMi0wMy0yNCAyMzozMDowNSIK KyAgICAgICAgICAgICAgICAgICAgICAgKGZvcm1hdC10aW1lLXN0cmluZworICAgICAgICAg ICAgICAgICAgICAgICAgIiVGICVUIgorICAgICAgICAgICAgICAgICAgICAgICAgKG9yZy1l bmNvZGUtdGltZSA1IDMwIDIzIDI0IDMgMjAyMiBuaWwpKSkpKSkKKyAgOzsgZGF5bGlnaHQg c2F2aW5nIHRpbWUKKyAgKG9yZy10ZXN0LXdpdGgtdGltZXpvbmUgIkV1cm9wZS9NYWRyaWQi CisgICAgKHNob3VsZCAoc3RyaW5nLWVxdWFsCisgICAgICAgICAgICAgIjIwMjItMDMtMzEg MjM6MzA6MDYiCisgICAgICAgICAgICAgKGZvcm1hdC10aW1lLXN0cmluZworICAgICAgICAg ICAgICAiJUYgJVQiCisgICAgICAgICAgICAgIChvcmctZW5jb2RlLXRpbWUgNiAzMCAyMyAz MSAzIDIwMjIpKSkpKSkKKwogKGVydC1kZWZ0ZXN0IHRlc3Qtb3JnL29yZy1yZWFkLWRhdGUg KCkKICAgIlRlc3QgYG9yZy1yZWFkLWRhdGUnIHNwZWNpZmljYXRpb25zLiIKICAgOzsgUGFy c2UgSVNPIGRhdGUgd2l0aCBhYmJyZXZpYXRlZCB5ZWFyIGFuZCBtb250aC4KLS0gCjIuMjUu MQoK --------------Iz3eYep8zRry2Hp1Vfj9thTo--