mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-24 22:10:13 +00:00
ee768a30fe
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. |
||
---|---|---|
.. | ||
bits/types | ||
sys | ||
adjtime.c | ||
alt_digit.c | ||
asctime.c | ||
bug-asctime_r.c | ||
bug-asctime.c | ||
bug-getdate1.c | ||
bug-mktime1.c | ||
bug-mktime4.c | ||
clock_getcpuclockid.c | ||
clock_getres.c | ||
clock_gettime.c | ||
clock_nanosleep.c | ||
clock_settime.c | ||
clock.c | ||
clocktest.c | ||
ctime_r.c | ||
ctime.c | ||
Depend | ||
difftime.c | ||
dysize.c | ||
era.c | ||
ftime.c | ||
getdate.c | ||
getitimer.c | ||
gettimeofday.c | ||
gmtime.c | ||
lc-time-cleanup.c | ||
localtime.c | ||
Makefile | ||
mktime-internal.h | ||
mktime.c | ||
offtime.c | ||
setitimer.c | ||
settimeofday.c | ||
settimezone.c | ||
stime.c | ||
strftime_l.c | ||
strftime.c | ||
strptime_l.c | ||
strptime.c | ||
test_time.c | ||
time.c | ||
time.h | ||
timegm.c | ||
timespec_get.c | ||
timespec_getres.c | ||
tst_wcsftime.c | ||
tst-adjtime-time64.c | ||
tst-adjtime.c | ||
tst-clock2-time64.c | ||
tst-clock2.c | ||
tst-clock_nanosleep-time64.c | ||
tst-clock_nanosleep.c | ||
tst-clock_settime-time64.c | ||
tst-clock_settime.c | ||
tst-clock-time64.c | ||
tst-clock.c | ||
tst-cpuclock1-time64.c | ||
tst-cpuclock1.c | ||
tst-ctime-time64.c | ||
tst-ctime.c | ||
tst-difftime-time64.c | ||
tst-difftime.c | ||
tst-ftime_l.c | ||
tst-ftime.c | ||
tst-getdate.c | ||
tst-gmtime-time64.c | ||
tst-gmtime.c | ||
tst-itimer-time64.c | ||
tst-itimer.c | ||
tst-mktime2.c | ||
tst-mktime3.c | ||
tst-mktime4-time64.c | ||
tst-mktime4.c | ||
tst-mktime.c | ||
tst-posixtz.c | ||
tst-settimeofday-time64.c | ||
tst-settimeofday.c | ||
tst-strftime2.c | ||
tst-strftime3.c | ||
tst-strftime4-time64.c | ||
tst-strftime4.c | ||
tst-strftime.c | ||
tst-strptime2.c | ||
tst-strptime3.c | ||
tst-strptime-whitespace.c | ||
tst-strptime.c | ||
tst-timegm-time64.c | ||
tst-timegm.c | ||
tst-timespec_get-time64.c | ||
tst-timespec_get.c | ||
tst-timespec_getres-time64.c | ||
tst-timespec_getres.c | ||
tst-tzname.c | ||
tst-y2039-time64.c | ||
tst-y2039.c | ||
tzfile.c | ||
tzset.c | ||
Versions | ||
wcsftime_l.c | ||
wcsftime.c |