From patchwork Sun Oct 10 10:52:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 46038 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D2A33858421 for ; Sun, 10 Oct 2021 10:54:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D2A33858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1633863251; bh=9oTiHpy4U9hpuEoZ1bHLE3an0CPZV8uSlMFgo0TbpuU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=THemAEFm+XXjYJzcV2dlKCTiAIakaCdLIdZpKAxj+oJuprpLmqp37mPpw811cs2Qx VRf0u5afk1wNQOR6ltKY+7wQJAKDT+xO58rIbsCKTOxluzx6mfETEGg65KkBI0tB9O nWwhfJB3XhtUTLVehQGVZSoPV4NPGsk5Ajgo1GPc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 896643858D3C for ; Sun, 10 Oct 2021 10:53:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 896643858D3C Received: by mail-wr1-x42d.google.com with SMTP id r18so45599670wrg.6 for ; Sun, 10 Oct 2021 03:53:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9oTiHpy4U9hpuEoZ1bHLE3an0CPZV8uSlMFgo0TbpuU=; b=tmq7wi9woYXHlt4Pbfr6qwNIFUSPSJeUQ2KK7nRG1jWgND0pkmWWWTzs5yqbggsHWN gxlRwLnp8OuFyzJLPpWSPxQu9ImBuD7OYgtdHTt7ZnHzDYqfjwT85+3l/CwQaP7bxzhK oyDYHkZX+uEIU9nRejNd0nTyX/tMWPUMKX4+iI2IV+P5w47RpLE7cwfWf5pK10ZmLPgU sud87Z98SSPeGXL3u+NbKFcQsCd5B4HCwAJBXhr1L/mb+OaNTQpRwvf8WbwaCfJ7MoMl lll7qTLeAxyBhOp1ZnLvqubOTuAJl1UrQbSKrEM4tO9a2nlHuy9F5SkO6J8iri2veiC/ dW0A== X-Gm-Message-State: AOAM5337pWox2pb7zlX+qdBpHhOv5p8FOkiCKLMpotqD+ed42G31cwC1 R86wA5kuOOopE4qNw0h9H4M= X-Google-Smtp-Source: ABdhPJzeYGQS5hPUV4z42ynNqaoBCVB51n8rIisfxlGX4uJ2DssnzxPpvdwvwZtBmfB9IW2PyUY+pQ== X-Received: by 2002:a1c:6a07:: with SMTP id f7mr13591709wmc.7.1633863229713; Sun, 10 Oct 2021 03:53:49 -0700 (PDT) Received: from sqli.sqli.com ([195.53.121.100]) by smtp.googlemail.com with ESMTPSA id k6sm4890691wri.83.2021.10.10.03.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Oct 2021 03:53:49 -0700 (PDT) To: mtk.manpages@gmail.com, linux-man@vger.kernel.org Subject: [PATCH] ctime.3: mktime() may modify tm_hour due to tm_isdst Date: Sun, 10 Oct 2021 12:52:46 +0200 Message-Id: <20211010105245.53896-1-alx.manpages@gmail.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alejandro Colomar via Libc-alpha From: Alejandro Colomar Reply-To: Alejandro Colomar Cc: Alejandro Colomar , libc-alpha@sourceware.org Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" If the input DST value is the opposite of the one that mktime() uses, which comes from the current system timezone (see tzset(3)), mktime() will modify the hour (and if it's in a day limit, it may carry up to modify other fields) to normalize the time to the correct DST. If a user wants to avoid this, it should use UTC time, which never has DST. For that, setenv("TZ", "", 1); sets UTC time for the program. After that, the program should specify that DST is not in effect, by setting tm_isdst to 0 (or let the system guess it with -1), since setting tm_isdst to a positive value will result in an error, (probably) due to mktime() considering that it is invalid to have DST enabled for UTC times. Cc: Paul Eggert Signed-off-by: Alejandro Colomar --- man3/ctime.3 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/man3/ctime.3 b/man3/ctime.3 index 0e2068a09..7a5714be8 100644 --- a/man3/ctime.3 +++ b/man3/ctime.3 @@ -260,6 +260,13 @@ normalized (so that, for example, 40 October is changed into 9 November); is set (regardless of its initial value) to a positive value or to 0, respectively, to indicate whether DST is or is not in effect at the specified time. +If the initial value of +.I tm_isdst +is inconsistent with the one set by +.BR mktime (), +.I tm_hour +(and possibly other fields) +will be modified to normalize the time to the correct DST. Calling .BR mktime () also sets the external variable \fItzname\fP with