Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!decvax!decwrl!amdcad!lll-crg!seismo!ut-sally!std-unix
From: std-u...@ut-sally.UUCP
Newsgroups: mod.std.unix
Subject: ctime - HP proposal
Message-ID: <6572@ut-sally.UUCP>
Date: Sat, 13-Dec-86 12:41:53 EST
Article-I.D.: ut-sally.6572
Posted: Sat Dec 13 12:41:53 1986
Date-Received: Mon, 15-Dec-86 22:37:40 EST
Organization: IEEE P1003 Portable Operating System for Computer Environments 
Committee
Lines: 163
Approved: j...@sally.utexas.edu

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

Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!ut-sally!std-unix
From: std-u...@ut-sally.UUCP (Moderator, John Quarterman)
Newsgroups: mod.std.unix
Subject: Re: strftime et al.
Message-ID: <6708@ut-sally.UUCP>
Date: Tue, 23-Dec-86 12:05:01 EST
Article-I.D.: ut-sally.6708
Posted: Tue Dec 23 12:05:01 1986
Date-Received: Tue, 23-Dec-86 21:50:49 EST
References: <6572@ut-sally.UUCP>
Organization: IEEE P1003 Portable Operating System for Computer Environments 
Committee
Lines: 34
Approved: j...@sally.utexas.edu

From: ch...@mimsy.umd.edu (Chris Torek)
To: std-u...@sally.utexas.edu, hpfcdg!rgt%hplabs.cs...@relay.cs.net
Date: Mon, 15 Dec 86 16:25:27 EST

The time string formats seem to express a fair number of similar
numeric entities:
...
>	%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)
...
>	%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]
...
>	%y is replaced by the year without century (00 to 99)
>	%Y is replaced by the year with century

Now, time conversion may or may not be anywhere near as complex a
task as terminal control, but it seems to me that we may be repeating
the mistake made with termcap, repaired in terminfo.  Rather than
defining a specific set of numeric values, perhaps strftime, like
terminfo, should have a small calculator built in.  Then, e.g.,
`%y' and `%Y' are unnecessary.  `%y' could push the year-with-century,
and `%{100}' the value 100; invoking mod (`%%'? the name may prove
problematical) and `%2d' could then produce the year-without-century.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!mimsy!chris	ARPA/CSNet:	ch...@mimsy.umd.edu

Volume-Number: Volume 8, Number 70

Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!rutgers!im4u!ut-sally!std-unix
From: std-u...@ut-sally.UUCP (Moderator, John Quarterman)
Newsgroups: mod.std.unix
Subject: Re: ctime - HP proposal - bug
Message-ID: <6712@ut-sally.UUCP>
Date: Tue, 23-Dec-86 13:20:48 EST
Article-I.D.: ut-sally.6712
Posted: Tue Dec 23 13:20:48 1986
Date-Received: Tue, 23-Dec-86 22:43:00 EST
References: <6572@ut-sally.UUCP>
Organization: IEEE P1003 Portable Operating System for Computer Environments 
Committee
Lines: 26
Approved: j...@sally.utexas.edu

From: colonel%buffalo.cs...@relay.cs.net 
Date: Tue, 16 Dec 86 12:29:00 EST

> 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.  ...
>
> 	%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)

While I like the overall idea, this part needs work.

1. Is week 01 the first complete week?  Or is week 00 the first full week
   or fragment of one?

2. If the year begins on Saturday and ends on Monday, it will have 54
   weeks.  Obviously they cannot be numbered 00 to 52!

By the way, how about using %P for AM/PM and %p for am/pm?

Volume-Number: Volume 8, Number 74

Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!ut-sally!std-unix
From: std-u...@ut-sally.UUCP (Moderator, John Quarterman)
Newsgroups: mod.std.unix
Subject: Re: strftime et al.
Message-ID: <6780@ut-sally.UUCP>
Date: Wed, 7-Jan-87 18:20:22 EST
Article-I.D.: ut-sally.6780
Posted: Wed Jan  7 18:20:22 1987
Date-Received: Thu, 8-Jan-87 00:05:41 EST
References: <6572@ut-sally.UUCP> <6708@ut-sally.UUCP>
Organization: IEEE P1003 Portable Operating System for Computer Environments 
Committee
Lines: 24
Approved: j...@sally.utexas.edu
Summary: terminfo uses %m for mod

From: cbosgd!m...@seismo.css.gov (Mark Horton)
Date: Wed, 24 Dec 86 17:50:53 est
Organization: AT&T Medical Information Systems, Columbus

>`%y' and `%Y' are unnecessary.  `%y' could push the year-with-century,
>and `%{100}' the value 100; invoking mod (`%%'? the name may prove
>problematical)

Terminfo uses %m for mod to get around the obvious problem of using
%% to get a literal %.

Chris makes a very good point.  Another observation is that there
are lots of special pieces of the date you might want; rather than
giving them a separate letter each, you could group them as
parameters in a standard vector.  Thus, %p1 might get the hours
rather than %H.  If you like the mnemonics, %pH might be a
synonym.  The idea here is that a vector is more easily extended,
and you don't have to be so careful about using up the space of
letters.  This makes it easier to be printf-compatible.

	Mark


Volume-Number: Volume 9, Number 4