Document use of Time Tool Set by gmtime and strftime.

Also include some tests for strftime %z and %Z conversions (although just producing no output will satisfy them).
This commit is contained in:
Stephen Heumann 2022-12-28 19:57:19 -06:00
parent 7d3f1c8dd7
commit f7a139b4b5
2 changed files with 28 additions and 2 deletions

View File

@ -67,6 +67,24 @@ int main(void) {
if (strftime(buf, 1, "%A", &tm) != 0)
goto Fail;
len = strftime(buf, sizeof(buf), "%z", &tm);
if (len != 0) {
if (len != 5)
goto Fail;
if (buf[0] != '-' && buf[0] != '+')
goto Fail;
if (buf[1] < '0' || buf[1] > '2')
goto Fail;
if (buf[2] < '0' || buf[2] > '9')
goto Fail;
if (buf[3] < '0' || buf[3] > '5')
goto Fail;
if (buf[4] < '0' || buf[4] > '9')
goto Fail;
}
strftime(buf, sizeof(buf), "%Z", &tm); /* format can vary */
printf ("Passed Conformance Test c99strftim\n");
return 0;

View File

@ -1044,14 +1044,16 @@ The conversion specifiers are:
%X - time (equivalent to "%T" in the "C" locale)
%y - last two digits of the year (00-99)
%Y - year (e.g. 1986)
%z - time zone offset from UTC, if available (writes nothing in ORCA/C)
%Z - time zone name or abbreviation, if available (writes nothing in ORCA/C)
%z - time zone offset from UTC in hours and minutes (e.g. +0430), if available
%Z - time zone name or abbreviation, if available
%% - replaced by %
Some conversion specifiers can also include an "E" or "O" modifier (e.g. "%Ec"). These might cause an alternate format to be used in certain locales, but in the "C" locale these modifiers are ignored.
The %g, %G, and %V specifiers are based on the ISO 8601 week-based year, in which weeks begin on a Monday and week 01 of a year is the week that includes January 4. According to this system, the first few days of some years are considered to be in week 52 or 53 of the previous year, and the last few days of some years are considered to be in week 01 of the next year.
If the Time Tool Set by Geoff Weiss is installed and active, the %z and %Z specifiers will use it to obtain the time zone offset. (In ORCA/C, the %Z specifier currently represents the time zone in the same numeric format as %z.) If the Time Tool Set is not installed or has not been started, those specifiers will not produce any output. For more information on using the Time Tool Set, see the discussion of gmtime() below.
If strftime() is able to write the full formatted date/time string to s, it returns the total number of characters written, not including the terminating null. If it is not able to do so because the full size exceeds maxsize, then it returns 0 and the contents of s are unspecified.
12. (C89) The setlocale function has been added:
@ -1394,6 +1396,12 @@ long double strtold(const char * restrict str, char ** restrict ptr);
As currently implemented in ORCA/C, strtof and strtold behave identically to strtod, all giving values with the precision and range of long double.
20. If the Time Tool Set by Geoff Weiss is installed and active, then the gmtime() function will use it to determine the difference between the system's local time and UTC, and the structure produced will reflect the UTC time. If the Time Tool Set is not installed or has not been started, then gmtime() will assume that the system's local time is equal to UTC, as it did previously.
Note that the ORCA/C run-time libraries will not start up the Time Tool Set. If you want library functions to use it, your program will need to include code to load it and start it up before you make any library calls that would use it, and then to shut it down and unload it before the program exits. See the Time Tool Set website for more information and downloads:
https://timetool.gwlink.net
-- Compiler changes introduced in C 2.1.0 -----------------------------------
The Default .h File