emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug#54764: encode-time: make DST and TIMEZONE fields of the list arg


From: Paul Eggert
Subject: Re: bug#54764: encode-time: make DST and TIMEZONE fields of the list argument optional ones
Date: Wed, 20 Apr 2022 12:17:47 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0

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 more impressive as impossible date.

Thanks, good idea; also in the attached patch.


I can not figure out which elisp function can help to determine wall time for Aug 1 start of day in Cairo:

Africa/Cairo  Thu Jul 31 21:59:59 2014 UT = Thu Jul 31 23:59:59 2014 EET isdst=0 gmtoff=7200 Africa/Cairo  Thu Jul 31 22:00:00 2014 UT = Fri Aug  1 01:00:00 2014 EEST isdst=1 gmtoff=10800

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 arbitrary timestamps, since 00:00 doesn't exist in Cairo that day. Worse, in some locations near the International Date Line entire days do not exist, because at 00:00 they advanced the clocks forward 24 hours in order to move the date line.

It sounds like you're asking for a function that, given a date, yields the first broken-down timestamp on or after 00:00 of that date. For something like that, I'd use encode-time on 00:00 of that date to get a timestamp T, and then use time-add and decode-time to decode T-86400 seconds, T, and T+86400 seconds, and if the decoded times all look fine then return (decode-time T). If not (i.e., their UTC offsets differ, or T's decoded time is not 00:00 on the correct date) I'd use binary search to find discontinuities between T-86400 and T+86400 and look next to those discontinuities to find timestamps closer to what you want.

Of course this is not ideal - but it's similar to what many mktime implementations do internally, and it's also similar to what Emacs's cal-dst already does (maybe you can look there for ideas), so you'd be in good company.

Attachment: 0001-More-encode-time-pitfall-doc-fixes.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]