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.