glibc/time
Paul Eggert ee768a30fe Modernize and fix doc’s “Date and Time” (BZ 31876)
POSIX.1-2024 (now official) specifies tm_gmtoff and tm_zone.
This is a good time to update the manual’s “Date and Time”
chapter so I went through it, fixed some outdated
stuff that had been in there for decades, and improved it to match
POSIX.1-2024 better and to clarify some implementation-defined
behavior.  Glibc already conforms to POSIX.1-2024 in these matters, so
this is merely a documentation change.

* manual/examples/strftim.c: Use snprintf instead of now-deprecated
  function asctime.  Check for localtime failure.  Simplify by using
  puts instead of fputs.  Prefer ‘buf, sizeof buf’ to less-obvious
  ‘buffer, SIZE’.

* manual/examples/timespec_subtract.c: Modernize to use struct
  timespec not struct timeval, and rename from timeval_subtract.c.
  All uses changed.  Check for overflow.  Do not check for negative
  return value, which ought to be OK since negative time_t is OK.
  Use GNU indenting style.

* manual/time.texi:

  Document CLOCKS_PER_SEC, TIME_UTC, timespec_get, timespec_getres,
  strftime_l.

  Document the storage lifetime of tm_zone and of tzname.

  Caution against use of tzname, timezone and daylight, saying that
  these variables have unspecified values when TZ is geographic.
  This is what glibc actually does (contrary to what the manual said
  before this patch), and POSIX is planned to say the same thing
  <https://austingroupbugs.net/view.php?id=1816>.
  Also say that directly accessing the variables is not thread-safe.

  Say that localtime_r and ctime_r don’t necessarily set time zone
  state.  Similarly, in the tzset documentation, say that it is called
  by ctime, localtime, mktime, strftime, not that it is called by all
  time conversion functions that depend on the time zone.

  Say that tm_isdst is useful mostly just for mktime, and that
  other uses should prefer tm_gmtoff and tm_zone instead.

  Do not say that strftime ignores tm_gmtoff and tm_zone, because
  it doesn’t do that.

  Document what gmtime does to tm_gmtoff and tm_zone.

  Say that the asctime, asctime_r, ctime, and ctime_r are now deprecated
  and/or obsolescent, and that behavior is undefined if the year is <
  1000 or > 9999.  Document strftime before these now-obsolescent
  functions, so that readers see the useful function first.

  Coin the terms “geographical format” and “proleptic format” for the
  two main formats of TZ settings, to simplify exposition.  Use this
  wording consistently.

  Update top-level proleptic syntax to match POSIX.1-2024, which glibc
  already implements.  Document the angle-bracket quoted forms of time
  zone abbreviations in proleptic TZ.  Say that time zone abbreviations
  can contain only ASCII alphanumerics, ‘+’, and ‘-’.

  Document what happens if the proleptic form specifies a DST
  abbreviation and offset but omits the rules.  POSIX says this is
  implementation-defined so we need to document it.  Although this
  documentation mentions ‘posixrules’ tersely, we need to rethink
  ‘posixrules’ since I think it stops working after 2038.

  Clarify wording about TZ settings beginning with ‘;’.

  Say that timegm is in ISO C (as of C23).

  Say that POSIX.1-2024 removed gettimeofday.

  Say that tm_gmtoff and tm_zone are extensions to ISO C, which is
  clearer than saying they are invisible in a struct ISO C enviroment,
  and gives us more wiggle room if we want to make them visible in
  strict ISO C, something that ISO C allows.

  Drop mention of old standards like POSIX.1c and POSIX.2-1992 in the
  text when the history is so old that it’s no longer useful in a
  general-purpose manual.

  Define Coordinated Universal Time (UTC), time zone, time zone ruleset,
  and POSIX Epoch, and use these phrases more consistently.

  Improve TZ examples to show more variety, and to reflect current
  practice and timestamps.  Remove obsolete example about Argentina.
  Add an example for Ireland.

  Don’t rely on GCC extensions when explaining ctime_r.

  Do not say that difftime produces the mathematically correct result,
  since it might be inexact.

  For clock_t don’t say “as in the example above” when there is no
  such example, and don’t say that casting to double works “properly
  and consistently no matter what”, as it suffers from rounding and
  overflow.

  Don’t say broken-down time is not useful for calculations; it’s
  merely painful.

  Say that UTC is not defined before 1960.

  Rename Time Zone Functions to Time Zone State.  All uses changed.

  Update Internet RFC 822 → 5322, 1305 → 5905.  Drop specific years of
  ISO 8601 as they don’t matter.

  Minor style changes: @code{"..."} → @t{"..."} to avoid overquoting in
  info files, @code → @env for environment variables, Daylight Saving
  Time → daylight saving time, white space → whitespace, prime meridian
  → Prime Meridian.
2024-06-15 08:53:50 -07:00
..
bits/types Always define __USE_TIME_BITS64 when 64 bit time_t is used 2024-04-02 15:28:36 -03:00
sys Always define __USE_TIME_BITS64 when 64 bit time_t is used 2024-04-02 15:28:36 -03:00
adjtime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
alt_digit.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
asctime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
bug-asctime_r.c [BZ #1468] 2005-10-14 17:20:58 +00:00
bug-asctime.c [BZ #1460] 2005-10-14 15:17:40 +00:00
bug-getdate1.c support: Introduce new subdirectory for test infrastructure 2016-12-09 08:18:27 +01:00
bug-mktime1.c [BZ #2821] 2006-09-09 16:56:29 +00:00
bug-mktime4.c mktime: new test for mktime failure 2018-11-15 22:59:33 +01:00
clock_getcpuclockid.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
clock_getres.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
clock_gettime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
clock_nanosleep.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
clock_settime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
clock.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
clocktest.c Add missing header files throughout the testsuite. 2017-02-16 17:33:18 -05:00
ctime_r.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
ctime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
Depend * time/Makefile (tst-getdate-ENV): Add TZDIR to environment. 2001-07-18 09:43:36 +00:00
difftime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dysize.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
era.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
ftime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
getdate.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
getitimer.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gettimeofday.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gmtime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
lc-time-cleanup.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
localtime.c Modernize and fix doc’s “Date and Time” (BZ 31876) 2024-06-15 08:53:50 -07:00
Makefile Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
mktime-internal.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
mktime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
offtime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
setitimer.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
settimeofday.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
settimezone.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
stime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
strftime_l.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
strftime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
strptime_l.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
strptime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
test_time.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
time.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
time.h difftime can throw exceptions 2024-06-04 09:04:04 -07:00
timegm.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
timespec_get.c time: Allow later version licensing. 2024-05-01 09:03:26 -04:00
timespec_getres.c time: Allow later version licensing. 2024-05-01 09:03:26 -04:00
tst_wcsftime.c Don't use the argument to time. 2019-08-21 08:26:36 -04:00
tst-adjtime-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-adjtime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-clock2-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-clock2.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-clock_nanosleep-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-clock_nanosleep.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-clock_settime-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-clock_settime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-clock-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-clock.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-cpuclock1-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-cpuclock1.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-ctime-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-ctime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-difftime-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-difftime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-ftime_l.c Modify several tests to use test-skeleton.c 2014-11-05 15:24:08 +05:30
tst-ftime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-getdate.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-gmtime-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-gmtime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-itimer-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-itimer.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-mktime2.c time/tst-mktime2: Improve test error reporting 2018-10-23 11:25:05 +02:00
tst-mktime3.c Modify several tests to use test-skeleton.c 2014-11-05 15:24:08 +05:30
tst-mktime4-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-mktime4.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-mktime.c Modify several tests to use test-skeleton.c 2014-11-05 15:24:08 +05:30
tst-posixtz.c Add missing header files throughout the testsuite. 2017-02-16 17:33:18 -05:00
tst-settimeofday-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-settimeofday.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-strftime2.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-strftime3.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-strftime4-time64.c Use 64-bit time_t interfaces in strftime and strptime (bug 30053) 2023-02-07 10:15:09 +01:00
tst-strftime4.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-strftime.c Use '%z' instead of '%Z' on printf functions 2022-09-22 08:48:04 -03:00
tst-strptime2.c Fix all the remaining misspellings -- BZ 25337 2023-06-02 01:39:48 +00:00
tst-strptime3.c time: ensure failing strptime() tests are reported correctly 2015-03-06 06:06:26 -05:00
tst-strptime-whitespace.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-strptime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-timegm-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-timegm.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-timespec_get-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-timespec_get.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-timespec_getres-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-timespec_getres.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-tzname.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-y2039-time64.c y2038: Add test coverage 2021-06-15 10:42:11 -03:00
tst-y2039.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tzfile.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tzset.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
Versions Add C2X timespec_getres 2021-05-17 20:55:21 +00:00
wcsftime_l.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
wcsftime.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00