[mod.std.unix] ctime - HP proposal

std-unix@ut-sally.UUCP (12/13/86)

References:

From: utah-cs!hplabs!hpfcla!hpfclj!hpfcdg!rgt (Ron Tolley)
Date: Wed, 10 Dec 86 18:51:58 est

The HP proposal  boils down to five  changes to the RFC.001  Timezone
Interface  by Robert Elz.  I have  listed  these in order of  importance
with  exception  of the  first  (which  is  really  just a  change  to a
comment).  As it turns out they are also in the order  that  they  would
appear in RFC.001.

[ RFC.001 has been superseded by P.55, which I reposted recently.  -mod ]

<(1) Replace (if it makes any difference) the paragraph>

So, I'm going to propose something that could be inserted into
P1003 (with the obvious extra definitions that I'm going to
leave out on the assumption that everyone knows what they are,
like the definition of the struct "tm").

<with the paragraph>

So, I'm going to propose something that could be inserted into
P1003 (with the obvious extra definitions that I'm going to
leave out on the assumption that everyone knows what they are.)

<(2) Replace the paragraph>

Implementations shall provide the following functions:

	struct tm *gmtime(t) time_t *t;
	struct tm *localtime(t) time_t *t;
	int settz(p) char *p;
	char *asctime(tp) struct tm *tp;
	char *ctime(t) time_t *t;

<with the following paragraphs>

The "tm" structure shall be defined as:

	struct tm {
		int tm_sec;	/\(** seconds (0 - 59) \(**/
		int tm_min;	/\(** minutes (0 - 59) \(**/
		int tm_hour;	/\(** hours (0 - 23) \(**/
		int tm_mday;	/\(** day of month (1 - 31) \(**/
		int tm_mon;	/\(** month of year (0 - 11) \(**/
		int tm_year;	/\(** year \- 1900 \(**/
		int tm_wday;	/\(** day of week (Sunday = 0) \(**/
		int tm_yday;	/\(** day of year (0 - 365) \(**/
		int tm_isdst;	/\(** is DST in effect? \(**/
		long tm_tzadj;	/\(** time zone adjustment \(**/
		char *tm_tnptr;	/\(** points to time zone name \(**/
	};

where  tm_isdst is non-zero if a time zone  adjustment  such as Daylight
Savings Time is in effect,  tm_tzadj is the  difference  between GMT and
local  time  expressed  in  seconds,  and  tm_tnptr  points  to a string
containing the time zone abbreviation.

The tm_isdst,  tm_tzadj, and tm_tnptr members of the tm structure may be
viewed as equivalents to the daylight,  timezone, and tzname[]  external
variables  however  their  values  track  those  in the  rest  of the tm
structure.

Implementations shall provide the following functions:

	struct tm *gmtime(t) time_t *t;
	struct tm *localtime(t) time_t *t;
	int settz(p) char *p;
	char *asctime(tp) struct tm *tp;
	char *ctime(t) time_t *t;
	int strftime (p, n, f, tp) char *p, int n, char *f, struct tm *tp;
	int strctime (p, n, f, t) char *p, int n, char *f, time_t *t;
	time_t mktime (tp) struct tm *tp;

<(3) Add after the paragraph describing ctime the following paragraphs>

strftime:  supports  formatted  output of date and time,  according to a
user-supplied  format string.  Locale-specific  values such as month and
weekday names are provided  according to the currently  defined  locale.
(The  method  of  setting  locale  will  be  addressed   elsewhere.  The
setlocale  or  nl_init   routines  are   currently   available  in  some
implementations.)  Strftime  limits the length of the return string p to
be  no  greater  than  n  characters  (including  the  terminating  null
character).  The  actual  number  of  characters   (excluding  the  null
character)  included in p is returned by each  successful  call.  Unlike
asctime, no newline is automatically appended to the formatted string.

strctime:  also supports formatting but takes time_t *t as an argument.

format:  uses field  descriptors  similar to those in the first argument
to printf(3S).  Numeric  output fields are of fixed size (zero padded if
necessary).  All other  characters  are  copied  to the  output  without
change.  Field descriptors are expanded as follows:

	%a is replaced by the abbreviated weekday name

	%A is replaced by the full weekday name

	%b is replaced by the abbreviated month name

	%B is replaced by the full month name

	%c is replaced by the appropriate date and time representation

	%d is replaced by the day of the month as a decimal number (01
	   to 31)

	%H is replaced by the hour (24-hour clock) as a decimal number
	   (00 to 23)

	%I is replaced by the hour (12-hour clock) as a decimal number
	   (01 to 12)

	%j is replaced by the day of the year as a decimal number (001
	   to 366)

	%m is replaced by the month as a decimal number (01 to 12)

	%M is replaced by the minute as a decimal number (00 to 59)

	%n is replaced by a new-line character

	%p is replaced by the equivalent of AM or PM

	%r is replaced by the appropriate (12-hour clock) time
	   representation

	%S is replaced by seconds as a decimal number (00 to 59)

	%t is replaced by a tab character

	%U is replaced by the week number of the year with Sunday as the
	   first day of the week (00 to 52)

	%V is replaced by the week number of the year with Monday as the
	   first day of the week (00 to 52)

	%w is replaced by the weekday as a decimal number [0 (Sunday) to 6]

	%x is replaced by the appropriate date representation

	%X is replaced by the appropriate time representation

	%y is replaced by the year without century (00 to 99)

	%Y is replaced by the year with century

	%Z is replaced by the time zone name

	%% is replaced by %

<(4) Add the following paragraph after those mentioned in (3)>

mktime:  computes a long integer time value from a time value  contained
in a "tm" structure.  The values of tm_wday and tm_yday are  overwritten
during this computation.

<(5) Remove all references to settz().  Localtime will use the value of TZ
to determine the what local time means.  If TZ is not set, then localtime
will return a best guess at localtime.>

Ron Tolley

Volume-Number: Volume 8, Number 65