From nobody Thu Oct 2 08:20:42 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ccl9R1MWQz69KRd; Thu, 02 Oct 2025 08:20:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ccl9Q5wNBz4N1W; Thu, 02 Oct 2025 08:20:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759393242; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZSl/t5kyWMMQfSwJj91O4Qjuh9mrz0CoFQxi/G0bXUM=; b=TpXfr80r+M1WA75w2TKlVZ2zdYefE+AE/ndwGXdeBZR/TI42CGYTArYTZL9CdjKS50a1XI Wl+nkBa0FjqKFNDn/AGG4I2LZ0tJJH16pLPK+1QtnuFnqeARKE39gn/gA0xJcGZAGf1PcO 6MvzjJs4zZjBV9GGTSkJTSb7pIBDmS2I3vFmqi12RLyUgDL1ieYioo3ylnaxM8WI9UN1fq V59Bf24sZCCGOIBuIoIh5Tga5//OPfC4EPeMqRIwZlhvJnsLCKI6Rq8rCnjBtVcpzUqJlj Mh9Od2gAR/r5rokL5g0NwGHn99jgsUwDn7oLUk19KW8CIu/17+nIvxTkw5FHXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759393242; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZSl/t5kyWMMQfSwJj91O4Qjuh9mrz0CoFQxi/G0bXUM=; b=c4r0lYJOuMHWZKdG12Dji4WFg8eNd5NRzWzClAEGpS4eAlBlUg1niHcyjpIeRVrfa6B2yo Y+VVr1wnwJfZVQXkp8efoTm7qwHavoDoQa8j/O0bHWPEEBxU6BbtlYXkx6tIVCepcM89UY Dv2mGd7RuyxZn9g+Is2wLmwcBoCQPa8rC/NvyFqhSdyvBWY8bfrLIMmc3lh0sCXqQwqai4 JO+1ALC0lHTBAA3wu+rb8KfvLbEV123uq/Q/pQDr3My7jKS6y9VtxBfwdOn/ZfFcJIMbdg yG/HlGmw6GKch02nTy0DljMCSYfxafR+iwT97vMS8Hp9eIxvxGDrigQV7PF+Pw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1759393242; a=rsa-sha256; cv=none; b=gEDSTrzRj0kAoXq35gOM+deBj/JCQmoeVuCfJwzk2n2dfMioW+KVrJ2ZD7c/jYSRUvhRbw PiQACTl+fAYlhNszz9PBGu3J2aiRdz2Iyu9ZI0c62upidRLx6y0zPspqRg4YL6urxXjr1c seiXYhXlfj109YHr0WPHSCiqgvuyYkRN02UAhQPiRIDYuF/HEAT+x7cYuvNXIeSYYDM14S f/619bdC+9N6/AlVjxAEE+3fBHh8nJHQZ4brdk1FvDas2UAB49YM/74Hxo06govFGTVN9I mKeCcRHpvwplNOCRUwY98xsgRKUiHL8gd9Bm7aYW3CFA4mjGnsKyLbaknXf2LQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ccl9Q59wYzynv; Thu, 02 Oct 2025 08:20:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5928Kgn3023125; Thu, 2 Oct 2025 08:20:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5928KgN0023122; Thu, 2 Oct 2025 08:20:42 GMT (envelope-from git) Date: Thu, 2 Oct 2025 08:20:42 GMT Message-Id: <202510020820.5928KgN0023122@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: b28b04428732 - stable/15 - tzcode: Expose and document offtime() and offtime_r() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: b28b04428732b996aa29a79b8b3916c5cd7aa627 Auto-Submitted: auto-generated The branch stable/15 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=b28b04428732b996aa29a79b8b3916c5cd7aa627 commit b28b04428732b996aa29a79b8b3916c5cd7aa627 Author: Dag-Erling Smørgrav AuthorDate: 2025-09-23 18:52:10 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2025-10-02 08:19:23 +0000 tzcode: Expose and document offtime() and offtime_r() Includes diff reduction to upstream version of this patch. MFC after: 3 days Sponsored by: Klara, Inc. Reviewed by: philip Differential Revision: https://reviews.freebsd.org/D39715 (cherry picked from commit 155290b23f0b503b9db675d6a45f85b189ee1926) --- contrib/tzcode/localtime.c | 2 +- contrib/tzcode/private.h | 2 +- include/time.h | 2 ++ lib/libc/stdtime/ctime.3 | 39 +++++++++++++++++++++++++++++++++------ 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/contrib/tzcode/localtime.c b/contrib/tzcode/localtime.c index 7ba72d730648..a8f97e31a4bb 100644 --- a/contrib/tzcode/localtime.c +++ b/contrib/tzcode/localtime.c @@ -2021,7 +2021,7 @@ offtime_key_init(void) } #endif /* __FreeBSD__ */ struct tm * -offtime(const time_t *timep, long offset) +offtime(time_t const *timep, long offset) { # if !SUPPORT_C89 static struct tm tm; diff --git a/contrib/tzcode/private.h b/contrib/tzcode/private.h index 532d9ddc81c8..e6b206690b73 100644 --- a/contrib/tzcode/private.h +++ b/contrib/tzcode/private.h @@ -823,7 +823,7 @@ extern long altzone; struct tm *offtime(time_t const *, long); # endif # if TZ_TIME_T || !defined offtime_r -struct tm *offtime_r(time_t const *, long, struct tm *); +struct tm *offtime_r(time_t const *restrict, long, struct tm *restrict); # endif # if TZ_TIME_T || !defined timelocal time_t timelocal(struct tm *); diff --git a/include/time.h b/include/time.h index 89a76ca5fd93..9e71a85f6a9a 100644 --- a/include/time.h +++ b/include/time.h @@ -174,6 +174,8 @@ time_t timegm(struct tm * const); int timer_oshandle_np(timer_t timerid); time_t time2posix(time_t t); time_t posix2time(time_t t); +struct tm *offtime(const time_t *, long); +struct tm *offtime_r(const time_t *__restrict, long, struct tm *__restrict); #endif /* __BSD_VISIBLE */ #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) diff --git a/lib/libc/stdtime/ctime.3 b/lib/libc/stdtime/ctime.3 index 96b7f775535a..6384e8bd959b 100644 --- a/lib/libc/stdtime/ctime.3 +++ b/lib/libc/stdtime/ctime.3 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd March 26, 2024 +.Dd September 23, 2025 .Dt CTIME 3 .Os .Sh NAME @@ -41,6 +41,8 @@ .Nm localtime , .Nm localtime_r , .Nm mktime , +.Nm offtime , +.Nm offtime_r , .Nm timegm .Nd transform binary date and time values .Sh LIBRARY @@ -68,14 +70,19 @@ .Fn localtime_r "const time_t *clock" "struct tm *result" .Ft time_t .Fn mktime "struct tm *tm" +.Ft struct tm * +.Fn offtime "const time_t *clock" "long offset" +.Ft struct tm * +.Fn offtime_r "const time_t *clock" "long offset" "struct tm *result" .Ft time_t .Fn timegm "struct tm *tm" .Sh DESCRIPTION The .Fn ctime , .Fn gmtime , +.Fn localtime , and -.Fn localtime +.Fn offtime functions all take as argument a pointer to a time value representing the time in seconds since the Epoch (00:00:00 UTC on January 1, 1970; see @@ -123,6 +130,18 @@ adjustment, and returns a pointer to a .Vt struct tm . .Pp The +.Fn offtime +function similarly converts the time value with a time zone adjustment +corresponding to the provided +.Fa offset , +which is expressed in seconds, with positive values indicating a time +zone ahead of UTC (east of the Prime Meridian). +It does not call +.Xr tzset 3 +or modify +.Va tzname . +.Pp +The .Fn ctime function adjusts the time value for the current time zone in the same manner as @@ -155,13 +174,15 @@ except the caller must provide the output buffer .Fa buf , which must be at least 26 characters long, to store the result in. The -.Fn localtime_r +.Fn localtime_r , +.Fn gmtime_r , and -.Fn gmtime_r +.Fn offtime_r functions provide the same functionality as -.Fn localtime +.Fn localtime , +.Fn gmtime , and -.Fn gmtime +.Fn offtime respectively, except the caller must provide the output buffer .Fa result . .Pp @@ -368,6 +389,12 @@ and .Fn localtime_r functions have been available since .Fx 8.0 . +The +.Fn offtime +and +.Fn offtime_r +functions were added in +.Fx 15.0 . .Sh BUGS Except for .Fn difftime ,