A NOTE has been added to this issue. ====================================================================== https://austingroupbugs.net/view.php?id=1533 ====================================================================== Reported By: steffen Assigned To: ====================================================================== Project: 1003.1(2016/18)/Issue7+TC2 Issue ID: 1533 Category: Base Definitions and Headers Type: Enhancement Request Severity: Editorial Priority: normal Status: New Name: steffen Organization: User Reference: Section: time.h Page Number: 425 Line Number: 14451 Interp Status: --- Final Accepted Text: ====================================================================== Date Submitted: 2021-11-08 22:04 UTC Last Modified: 2021-11-22 15:26 UTC ====================================================================== Summary: struct tm: add tm_gmtoff (and tm_zone) field(s) ======================================================================
---------------------------------------------------------------------- (0005533) steffen (reporter) - 2021-11-22 15:26 https://austingroupbugs.net/view.php?id=1533#c5533 ---------------------------------------------------------------------- Re Note: 0005530 and Note: 0005531 I see. Yes, strftime(3) notes on page 2047 regarding %Z on TZ change! Standard is hard .. i had a single file DB with a TOC of names at the end pointing to data at the front, if a non-builtin one was needed then all was there to stay after being loaded. I see. musl does it like <code> const char *__tm_to_tzname(const struct tm *tm) { const void *p = tm->__tm_zone; LOCK(lock); do_tzset(); if (p != __utc && p != __tzname[0] && p != __tzname[1] && (!zi || (uintptr_t)p-(uintptr_t)abbrevs >= abbrevs_end - abbrevs)) p = ""; UNLOCK(lock); return p; } </code> therefore even using .tm_zone as a verification that %Z applies to the correct struct tm, which is an assertion beyond the usual "behaviour is undefined". Re 0005532: Oh! Indeed they use long not int, sorry! No, i do not know a system where this is int, actually -- sorry for this! I am afraid the standard cannot correct this; i personally never worked on a system where int was 16-bit, where that decision would make some sense. gmtoff_t does not seem to be needed: <code> #?0|kent:free-src.git$ git grep tm_gmtoff origin/main:include origin/main:include:time.h: long tm_gmtoff; /* offset from UTC in seconds */ #?0|kent:free-src.git$ cd ../open-src.git/ #?0|kent:open-src.git$ git grep tm_gmtoff origin/master:include origin/master:include:time.h: long tm_gmtoff; /* offset from UTC in seconds */ #?0|kent:open-src.git$ cd ../net-src.git/ #?0|kent:net-src.git$ git grep tm_gmtoff origin/trunk:include origin/trunk:include:time.h: long tm_gmtoff; /* offset from UTC in seconds */ #?0|kent:net-src.git$ cd ../dfly-src.git/ #?0|kent:dfly-src.git$ git grep tm_gmtoff origin/master:include origin/master:include:time.h: long tm_gmtoff; /* offset from UTC in seconds */ </code> ..even.. <code> #?0|kent:unix-hist$ git grep tm_gmtoff BSD-SCCS-END BSD-SCCS-END:usr/src/include/time.h: long tm_gmtoff; /* offset from CUT in seconds */ BSD-SCCS-END:usr/src/lib/libc/gen/ctime.3:long tm_gmtoff; /\(** offset from UTC in seconds \(**/ BSD-SCCS-END:usr/src/lib/libc/gen/ctime.3:.Fa tm_gmtoff BSD-SCCS-END:usr/src/lib/libc/gen/ctime.c: tmp->tm_gmtoff = offset; BSD-SCCS-END:usr/src/lib/libcompat/4.1/ftime.c: if (tm->tm_isdst) { /* tm_gmtoff has an offset applied */ BSD-SCCS-END:usr/src/lib/libcompat/4.1/ftime.c: tp->timezone = -localtime(&zero)->tm_gmtoff / 60; BSD-SCCS-END:usr/src/lib/libcompat/4.1/ftime.c: tp->timezone = -tm->tm_gmtoff / 60; BSD-SCCS-END:usr/src/share/zoneinfo/Makefile:# -DTM_GMTOFF=tm_gmtoff BSD-SCCS-END:usr/src/share/zoneinfo/Makefile:# -DTM_GMTOFF=_tm_gmtoff BSD-SCCS-END:usr/src/share/zoneinfo/Makefile:CFLAGS= -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone BSD-SCCS-END:usr/src/usr.bin/chpass/util.c: tval -= lt->tm_gmtoff; </code> and <code> #?128|kent:unix-hist$ git blame BSD-SCCS-END -- usr/src/include/time.h .. aec2dfdbbb2 (Keith Bostic 1989-03-08 23:45:57 -0800 49) long tm_gmtoff; /* offset from CUT in seconds */ aec2dfdbbb2 (Keith Bostic 1989-03-08 23:45:57 -0800 50) char *tm_zone; /* timezone abbreviation */ .. #?0|kent:unix-hist$ git blame aec2dfdbbb2^ -- usr/src/include/time.h ... 434fabe335c (Keith Bostic 1987-03-05 01:28:35 -0800 22) long tm_gmtoff; 434fabe335c (Keith Bostic 1987-03-05 01:28:35 -0800 23) char *tm_zone; </code> ..and we come to.. <code> commit 434fabe335c23dd3f16ab2d4ff3878b9bc69be50 Author: Keith Bostic <[email protected]> AuthorDate: 1987-03-05 01:28:35 -0800 Commit: Keith Bostic <[email protected]> CommitDate: 1987-03-05 01:28:35 -0800 added Robert Elz's additions for new time package SCCS-vsn: include/time.h 1.2 --- usr/src/include/time.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/usr/src/include/time.h b/usr/src/include/time.h index 8eb62c0453..0233380029 100644 --- a/usr/src/include/time.h +++ b/usr/src/include/time.h @@ -1,4 +1,10 @@ -/* time.h 1.1 85/03/13 */ +/* + * Copyright (c) 1983, 1987 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + * + * @(#)time.h 1.2 (Berkeley) %G% + */ /* * Structure returned by gmtime and localtime calls (see ctime(3)). @@ -13,6 +19,8 @@ struct tm { int tm_wday; int tm_yday; int tm_isdst; + long tm_gmtoff; + char *tm_zone; }; extern struct tm *gmtime(), *localtime(); </code> at which time i have to say Hello and a nice day dear Robert Elz! So given this is from 1987 i would think 34 years give the guarantee that all possible UNIX systems go for long here. Apologies! Issue History Date Modified Username Field Change ====================================================================== 2021-11-08 22:04 steffen New Issue 2021-11-08 22:04 steffen Name => steffen 2021-11-08 22:04 steffen Section => time.h 2021-11-08 22:04 steffen Page Number => 425 2021-11-08 22:04 steffen Line Number => 14451 2021-11-21 22:28 steffen Note Added: 0005529 2021-11-22 09:47 geoffclare Note Added: 0005530 2021-11-22 10:12 geoffclare Note Added: 0005531 2021-11-22 10:50 geoffclare Note Added: 0005532 2021-11-22 15:26 steffen Note Added: 0005533 ======================================================================
