From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 21B7B20CE5 for ; Sat, 23 Mar 2024 16:31:43 +0100 (CET) Received: (qmail 7358 invoked by uid 550); 23 Mar 2024 15:27:01 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 7320 invoked from network); 23 Mar 2024 15:27:00 -0000 Date: Sat, 23 Mar 2024 11:31:46 -0400 From: Rich Felker To: Alexander Weps Cc: musl@lists.openwall.com, Markus Wichmann Message-ID: <20240323153146.GS4163@brightrain.aerifal.cx> References: <528SeRFaPfDw7fA4kqKDlio1U4RB_t9nmUemPcWw9_t1e2hBDpXYFmOqxAC37szgYvAVtmTuXWsmT64SSN3cSQFVdrQqXUAgkdTMPZQ0bg0=@pm.me> <20240323123148.GR4163@brightrain.aerifal.cx> <5zS95V9QjlCRMv6JvbMFzFIOvxQTigAsEvu0YNSYzcu1ZHdki6sue6yqDXeWlRcSe_jhCQxHdHc0fvKu-3H7lCvyAeYgQTsK7KWMepbly3Y=@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5zS95V9QjlCRMv6JvbMFzFIOvxQTigAsEvu0YNSYzcu1ZHdki6sue6yqDXeWlRcSe_jhCQxHdHc0fvKu-3H7lCvyAeYgQTsK7KWMepbly3Y=@pm.me> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Broken mktime calculations when crossing DST boundary On Sat, Mar 23, 2024 at 01:49:48PM +0000, Alexander Weps wrote: > I don't think time can go backwards by incrementing field under any conditions. > > Going from: > tm_sec: 2 > tm_min: 60 > tm_hour: 1 > tm_mday: 31 > tm_mon: 2 > tm_year: 124 > tm_wday: 0 > tm_yday: 90 > tm_isdst: -1 > > To: > tm_sec: 2 > tm_min: 0 > tm_hour: 1 > tm_mday: 31 > tm_mon: 2 > tm_year: 124 > tm_wday: 0 > tm_yday: 90 > tm_isdst: 0 > > Seems to be plain wrong. I cannot come up with any argument for this > being correct under any conditions. The above broke-down time is 2:00:02, which does not exist on that day as a normalized time. If interpreted as non-DST, it would be just a couple seconds past the end of non-DST (1:59:59.99999..). If interpreted as DST, it would be just under an hour before the start of DST (3:00:00), which, after normalization, is 1:00:02 non-DST. mktime cannot tell whether your non-normalized input was the result of you starting with 01:00:02 and adding 1 hour (in which case, our output does not reflect your intent) or of you starting with 3:00:02 and subtracting 1 hour (in which case, our output does reflect your intent). > mktime was given a struct tm with uncertain STD/DST, it deduced it > is STD and then thrown away 60 minute information. The minutes got > reset from 60 to 0 and no other change was done. It did not deduce it was STD. It deduced it was non-normalized DST rather than non-normalized STD (this is an arbitrary choice), then normalized it and got STD. Rich