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=-2.9 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 9055F217EC for ; Sat, 23 Mar 2024 17:55:15 +0100 (CET) Received: (qmail 21834 invoked by uid 550); 23 Mar 2024 16:50:33 -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 21802 invoked from network); 23 Mar 2024 16:50:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1711212900; x=1711472100; bh=Kk+60UK8LBIKUokNMv4v/7AV4FcShi6TQhlLzPeH3kE=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=LVie1+p7eiIAyD11oRcHKCxjdJ5DEH58qPmH4wcf/MUr+XK8aqDG3qS0SUE9ZUzyx jZj5+5J/cg5FJiwxEeVzccAiCTOu+C5aJTiYpU7t9gr6h3A1NbAxdgweXPGbEbh6qb cKqDu8CGDHEY3uMgAIH5s6lgrMeJxQHWk3FSsd5k+XTwYaXJm9ZOdKXWWzLQ4jhsoK +VYDybeYkI3opbuhUM3T45kSBvvVMWgR8rDun138OXayBc+xnnIYK3beNoytFM2S9C 3tY1OJRke/w5ferVDwOi/XiBgm/sHpuj1gfVJmKlsvRWz2Byq5nMsUbDmmJMqeZ2g4 1GWkajclhIxpA== Date: Sat, 23 Mar 2024 16:54:53 +0000 To: musl@lists.openwall.com From: Alexander Weps Cc: Markus Wichmann Message-ID: <-44SZR0LbVoyD5lp_9VrAFnIjGNbDvibCVUYEprqMToPidjopTHM4aLZuhjomrGJtvpGrc_gjrgK6roKWwunjEkk1y-BKRhtlGpWjnslQNA=@pm.me> In-Reply-To: <20240323153146.GS4163@brightrain.aerifal.cx> References: <528SeRFaPfDw7fA4kqKDlio1U4RB_t9nmUemPcWw9_t1e2hBDpXYFmOqxAC37szgYvAVtmTuXWsmT64SSN3cSQFVdrQqXUAgkdTMPZQ0bg0=@pm.me> <20240323123148.GR4163@brightrain.aerifal.cx> <5zS95V9QjlCRMv6JvbMFzFIOvxQTigAsEvu0YNSYzcu1ZHdki6sue6yqDXeWlRcSe_jhCQxHdHc0fvKu-3H7lCvyAeYgQTsK7KWMepbly3Y=@pm.me> <20240323153146.GS4163@brightrain.aerifal.cx> Feedback-ID: 20507743:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [musl] Broken mktime calculations when crossing DST boundary One of the main purposes of struct tm is to calculate date and time, by add= ing and substracting it's fields. > 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). We are not adding hours here, your example is completely unrelated. We are adding or subtracting minutes that changes hours. tm_sec: 2 tm_min: 60 tm_hour: 1 vs tm_sec: 2 tm_min: 0 tm_hour: 2 And: tm_sec: 2 tm_min: 59 tm_hour: 1 vs tm_sec: 2 tm_min: -1 tm_hour: 2 AW On Saturday, March 23rd, 2024 at 16:31, Rich Felker wrote= : > 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 con= ditions. > > > > 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: 1 tm_min: 59 tm_hour: 2 > > 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