[mod.std.unix] strftime et al.

std-unix@ut-sally.UUCP (Moderator, John Quarterman) (12/23/86)

From: chris@mimsy.umd.edu (Chris Torek)
To: std-unix@sally.utexas.edu, hpfcdg!rgt%hplabs.csnet@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:	chris@mimsy.umd.edu

Volume-Number: Volume 8, Number 70

std-unix@ut-sally.UUCP (Moderator, John Quarterman) (01/08/87)

From: cbosgd!mark@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