From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id cM2mAokYV2LDOwAAgWs5BA (envelope-from ) for ; Wed, 13 Apr 2022 20:38:01 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id QH8dN4gYV2K9hgAAG6o9tA (envelope-from ) for ; Wed, 13 Apr 2022 20:38:00 +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 DB9F8D950 for ; Wed, 13 Apr 2022 20:37:59 +0200 (CEST) Received: from localhost ([::1]:54606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nehsM-0000wV-E0 for larch@yhetil.org; Wed, 13 Apr 2022 14:37:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nehqT-0000wF-DY for emacs-orgmode@gnu.org; Wed, 13 Apr 2022 14:36:01 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:60894) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nehqR-0006Ub-Ad for emacs-orgmode@gnu.org; Wed, 13 Apr 2022 14:36:00 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id A2A021600EB; Wed, 13 Apr 2022 11:35:56 -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 h68vYBwvfQrD; Wed, 13 Apr 2022 11:35:55 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C719B1600ED; Wed, 13 Apr 2022 11:35:55 -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 M0H0Bu3CdWZI; Wed, 13 Apr 2022 11:35:55 -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 9E2681600EB; Wed, 13 Apr 2022 11:35:55 -0700 (PDT) Message-ID: <2dd15844-01b3-0144-740c-185ec8488a81@cs.ucla.edu> Date: Wed, 13 Apr 2022 11:35:55 -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> 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: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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: emacs-orgmode@gnu.org, 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=1649875080; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=cV7XVwsk7c3iapgEIjtM7dyQW578OZ6/Ks9wXAAbYNM=; b=rBOcRVMC7xxVr3iJC9CJYj7ImuboHcne42kQdGUfU0Jf/bn/AmRZe3UPdeRu7U113HGiC1 EnqEXjg/7GyOzE0khLwcH7fqVS4kMXt9L7ynCtE7seuIAo0DoEv1LLEYnvzeM3CJdk73FN xWx0GrJFETSsJhcc4EStSQD7Nl9yqB+QPVkHLZ+3WJ1QNm3QPxpnKY9W6pGFfr8BI3vEhp U5Uc/KJ3wkHmV8K3biVjlCVRKBYT3/iFQ5WZlpTA8drD1MFcxw67y+VJ8RLqlN+46Kh3KJ XCi3WMKDoFsvdb+ItPchscQgz7DxoX5MMr+Vg85mKe8SaUWyD6MjPvb/KcJS6Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1649875080; a=rsa-sha256; cv=none; b=tduocmpJ9qh5gceNNWzM69DxWbMwysQKZfKDqPkQYaZW8SRrmxUzMz+P8eiRik/x7N6NPr 4eEQKGv+S2nftunFiMd/1S/13KwTeupWf1A7U24pO+Hr45yfeHvjiQRWPqulBpYa3IbPjK /AYBp2LR7Nxk5UbMqEnIaDgdhpfIK8OsitC/pF+/3hdWYXawR02TSadNC8OgGM4poRNfUg s/H3EAaS5IKedq21WXxj18GsMbkrsDkWl7ilouswyVGvdCCmuYbSJU/pMurU6Y5PFzUZAv RaON/mc1cOlbnG7z+cQIkn05WC6zCPbgznwl+O9fy90WZGE+jHO68G4AgAXmJA== 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.65 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: DB9F8D950 X-Spam-Score: -3.65 X-Migadu-Scanner: scn0.migadu.com X-TUID: hRk3J9FBoAtI On 4/13/22 07:40, Max Nikulin wrote: > > I do not see a way to get 23:30 EAT +0300. Are you asking for a function F where you say, "I want to give F a possibly-ambiguous decoded local time D, and for F to return all timestamps that map to D"? If so, encode-time doesn't do that, because the underlying C API (namely, mktime) doesn't do that. All mktime and encode-time do is give you *one* timestamp that maps to D; it won't give you any other timestamps. If you're worried about possibly-ambiguous decoded local times, you could probe (say) one day before and one day after encode-time's result to see if the UTC offset changes, and let that guide you to find other possible timestamps that map to the decoded time. Although this is just a heuristic it should be good enough. I doubt whether you need to do that, though. Code that is not careful about local time offsets doesn't care how ambiguous decoded times are resolved. And code that does care should record UTC offsets anyway, and you can use those offsets to disambiguate the decoded times. Something like this, say: (defun encode-and-format-time (time tz) (let ((etime (encode-time (parse-time-string time)))) (format-time-string "%F %T %Z %z" etime tz))) With this definition, (encode-and-format-time "2021-01-31 23:30:00 +0300" "Africa/Juba") yields "2021-01-31 23:30:00 EAT +0300", which is the timestamp you want. > `encode-time' should only accept time zone as time offset and should not allow default or named value that may be ambiguous. If we're talking about Org's encode-time substitute, you can of course do what you like. But Emacs encode-time has supported ambiguous timestamps for some time and I expect it's used by apps that don't care how ambiguous decoded times are resolved, which means we shouldn't remove that support without having a very good reason. > should be possible to provide hints to `encode-time' to get deterministic behavior in the case of time transitions Yes, that feature is already there. The hint is the UTC offset, as illustrated above.