Thread View: mod.std.unix
6 messages
6 total messages
Started by std-unix
Sat, 13 Dec 1986 17:41
ctime - HP proposal
Author: std-unix
Date: Sat, 13 Dec 1986 17:41
Date: Sat, 13 Dec 1986 17:41
165 lines
6492 bytes
6492 bytes
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
Re: strftime et al.
Author: Moderator, John Quarterman
Date: Tue, 23 Dec 1986 17:05
Date: Tue, 23 Dec 1986 17:05
34 lines
2078 bytes
2078 bytes
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
Re: ctime - HP proposal - bug
Author: Moderator, John Quarterman
Date: Tue, 23 Dec 1986 18:20
Date: Tue, 23 Dec 1986 18:20
26 lines
1482 bytes
1482 bytes
From: colonel%buffalo.csnet@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
Re: strftime et al.
Author: Moderator, John Quarterman
Date: Wed, 07 Jan 1987 23:20
Date: Wed, 07 Jan 1987 23:20
24 lines
1569 bytes
1569 bytes
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
Re: HP proposal - minor bug in bug
Author: Moderator, John Quarterman
Date: Wed, 07 Jan 1987 23:29
Date: Wed, 07 Jan 1987 23:29
16 lines
1181 bytes
1181 bytes
From: colonel%buffalo.csnet@relay.cs.net Date: Wed, 24 Dec 86 10:08:01 EST > From: colonel%buffalo.csnet@relay.cs.net > Date: Tue, 16 Dec 86 12:29:00 EST > > 2. If the year begins on Saturday and ends on Monday, it will have 54 > weeks. Obviously they cannot be numbered 00 to 52! Come to think of it, that would be a rather long year! But my point is valid if the year ends on the last day of the week (whatever day that is), and begins on the first day of the week. It might help to know what this feature would be used for. Volume-Number: Volume 9, Number 6
Re: HP proposal - minor bug in bug
Author: Moderator, John Quarterman
Date: Sun, 18 Jan 1987 00:37
Date: Sun, 18 Jan 1987 00:37
33 lines
1766 bytes
1766 bytes
From: seismo!enea!chalmers.UUCP!bergsten Date: Wed, 14 Jan 87 00:23:41 -0100 Organization: Dept. of CS, Chalmers, Sweden >From: colonel%buffalo.csnet@relay.cs.net >Date: Wed, 24 Dec 86 10:08:01 EST > >> From: colonel%buffalo.csnet@relay.cs.net >> Date: Tue, 16 Dec 86 12:29:00 EST >> >> 2. If the year begins on Saturday and ends on Monday, it will have 54 >> weeks. Obviously they cannot be numbered 00 to 52! > >Come to think of it, that would be a rather long year! ........ My pocket calendar states that according to swedish standard (which it claims was derived from ISO rules and formally accepted 1972): " .... Monday is regarded as the first day of the week, and the first week which has at least four days of the new year is week 1 ..." Apparently some international committee decided on how to number weeks 15 years ago!! It takes some courage to produce and publish a standard document when you know that at any time somebody may stumble on proud words of days past. Keep up the good work!! Regards, Per Bergsten ...!mcvax!enea!chalmers!bergsten.UUCP Volume-Number: Volume 9, Number 22
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads