From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 91E833858C74 for ; Thu, 8 Sep 2022 20:26:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 91E833858C74 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662668771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=LT8BmA/4v9hE5aBu9mxjwuDOTCWPuqDaK1icYw/Sz7k=; b=BoGHViLNVZ8yc9sE7iXRcAzBvTItvgnjVJMhk1cOgRE6L2h1vp3v/w2+E4QIud9Q8KHfXY 49zFOcuVuE0pk6KuNnrajcJSb6c34S3VMxqiDa6PQeWIyl/UZ7y5QUZhPrfzRKnW6RzMNx ua0mbF+TKSgLaq/n1OuSbKoSJOwvLwI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-274-v5fcFoWbMD2OyQZMN7Q0gg-1; Thu, 08 Sep 2022 16:26:09 -0400 X-MC-Unique: v5fcFoWbMD2OyQZMN7Q0gg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA9A31818803; Thu, 8 Sep 2022 20:26:07 +0000 (UTC) Received: from greed.delorie.com (unknown [10.22.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B39FB400EAB3; Thu, 8 Sep 2022 20:26:07 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.15.2/8.15.2) with ESMTP id 288KPvrS1435441; Thu, 8 Sep 2022 16:25:57 -0400 From: DJ Delorie To: Paul Eggert Cc: libc-alpha@sourceware.org Subject: Re: [swbz 29035] mktime vs non-DST In-Reply-To: Date: Thu, 08 Sep 2022 16:25:57 -0400 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HEXHASH_WORD,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > We have also seen a somewhat odd use of mktime() to detect DST transitions that > DJ and I need to audit and verify against the changes you have implemented in > gnulib. FYI we've finished this, with no problems :-) Paul Eggert writes: > From 674d4588995d24f8bc5167f73d8661ef5c82c2de Mon Sep 17 00:00:00 2001 > -# elif HAVE_TZSET > +# else Ok. > From bfe919ce3bba22178429c5b39db98c26fd83272e Mon Sep 17 00:00:00 2001 > Heuristic: probe the adjacent timestamps in both directions, > - looking for the desired isdst. This should work for all real > - time zone histories in the tz database. */ > + looking for the desired isdst. If none is found within a > + reasonable duration bound, assume a one-hour DST difference. > + This should work for all real time zone histories in the tz > + database. */ > + > + /* +1 if we wanted standard time but got DST, -1 if the reverse. */ > + int dst_difference = (isdst == 0) - (tm.tm_isdst == 0); Ok. > - /* The longest period of DST in tzdata2003a is 536454000 seconds > - (e.g., America/Jujuy starting 1946-10-01 01:00). The longest > - period of non-DST is much longer, but it makes no real sense > - to search for more than a year of non-DST, so use the DST > - max. */ > - int duration_max = 536454000; > + /* In TZDB 2021e, the longest period of DST (or of non-DST), in > + which the DST (or adjacent DST) difference is not one hour, > + is 457243209 seconds: e.g., America/Cambridge_Bay with leap > + seconds, starting 1965-10-31 00:00 in a switch from > + double-daylight time (-05) to standard time (-07), and > + continuing to 1980-04-27 02:00 in a switch from standard time > + (-07) to daylight time (-06). */ > + int duration_max = 457243209; Ok. > + /* No unusual DST offset was found nearby. Assume one-hour DST. */ > + t += 60 * 60 * dst_difference; > + if (mktime_min <= t && t <= mktime_max && convert_time (convert, t, &tm)) > + goto offset_found; > + > __set_errno (EOVERFLOW); > return -1; > } Ok. LGTM Reviewed-by: DJ Delorie