|
|
1.1 root 1: .TH GETDATE 3 unc
2: .SH NAME
3: getdate \- convert time and date from ASCII
4: .SH SYNOPSIS
5: .B #include <sys/types.h>
6: .br
7: .B #include <sys/timeb.h>
8: .PP
9: .B time_t getdate(buf, now)
10: .br
11: .B char *buf;
12: .br
13: struct timeb *now;
14: .SH DESCRIPTION
15: .I Getdate
16: converts common time specifications to standard UNIX
17: format.
18: .I Buf
19: is a character string containing the
20: time and date.
21: .I Now
22: is the assumed current time (used for relative
23: specifications); if the pointer is null (0)
24: .I ftime
25: (see
26: .IR time (2))
27: is used to obtain the current time and timezone.
28: .PP
29: The character string consists of 0 or more specifications of the following
30: form:
31: .TP
32: tod
33: A
34: .I tod
35: is a time of day, in the form
36: .IR hh : mm [: ss ]
37: (or
38: .IR hhmm )
39: .RI [ meridian ]
40: .RI [ zone ].
41: If no meridian \-
42: .B am
43: or
44: .B pm
45: \- is specified, a 24-hour clock is used.
46: A
47: .I tod
48: may be specified as just
49: .I hh
50: followed by a
51: .IR meridian.
52: .TP
53: date
54: A
55: .I date
56: is a specific month and day, and possibly a year. Acceptable formats are
57: .IR mm/dd [ /yy ]
58: and
59: .IR "monthname dd" "[, " yy ]
60: If omitted, the year defaults to the
61: current year; if a year is specified
62: as a number less than 100, 1900 is added.
63: If a number not followed by a day or relative time unit occurs, it will
64: be interpreted as a year if a
65: .IR tod ,
66: .IR monthname ,
67: and
68: .I dd
69: have already been specified; otherwise, it will be treated as a
70: .IR tod .
71: This rule allows the output from
72: .IR date (1)
73: or
74: .IR ctime (3)
75: to be passed as input to
76: .IR getdate .
77: .TP .75i
78: day
79: A
80: .I day
81: of the week may be specified; the current day will be used if appropriate.
82: A
83: .I day
84: may be preceeded by a
85: .IR number,
86: indicating which instance of that day is desired; the default is
87: .BR 1 .
88: Negative
89: .I numbers
90: indicate times past. Some symbolic
91: .I numbers
92: are accepted:
93: .BR last ,
94: .BR next ,
95: and the ordinals
96: .B first
97: through
98: .B twelfth
99: .RB ( second
100: is ambiguous, and is not accepted as an ordinal number).
101: The symbolic number
102: .B next
103: is equivalent to
104: .BR 2 ;
105: thus,
106: .I "next monday"
107: refers not to the immediately coming Monday, but to the one a week later.
108: .TP .75i
109: relative time
110: Specifications relative to the current time are also accepted.
111: The format is
112: .RI [ number "] " unit ;
113: acceptable units are
114: .BR year ,
115: .BR month ,
116: .BR fortnight ,
117: .BR week ,
118: .BR day ,
119: .BR hour ,
120: .BR minute ,
121: and
122: .BR second .
123: .PP
124: The actual date is formed as follows: first, any absolute date and/or time
125: is processed and converted. Using that time as the base, day-of-week
126: specifications are added; last, relative specifications are used. If a
127: date or day is specified, and no absolute or relative time is given, midnight
128: is used.
129: Finally, a correction is applied so that the correct hour of the day is
130: produced after allowing for daylight savings time differences.
131: .PP
132: .I Getdate
133: accepts most common abbreviations for days, months, etc.; in particular,
134: it will recognize them with upper or lower case first letter, and will
135: recognize three-letter abbreviations for any of them, with or without
136: a trailing period. Units, such as
137: .BR week s,
138: may be specified in the singular or plural. Timezone and meridian
139: values may be in upper or lower case, and with or without periods.
140: .SH FILES
141: /usr/lib/libu.a
142: .SH "SEE ALSO"
143: ctime(3), time(2)
144: .SH AUTHOR
145: Steven M. Bellovin (unc!smb)
146: .br
147: Dept. of Computer Science
148: .br
149: University of North Carolina at Chapel Hill
150: .SH BUGS
151: Because
152: .IR yacc (1)
153: is used to parse the date,
154: .I getdate
155: cannot be used a subroutine to any program that also needs
156: .IR yacc .
157: .br
158: The grammar and scanner are rather primitive; certain desirable and
159: unambiguous constructions are not accepted. Worse yet, the meaning of
160: some legal phrases is not what is expected;
161: .I next week
162: is identical to
163: .IR "2 weeks" .
164: .br
165: The daylight savings time correction is not perfect, and can get confused
166: if handed times between midnight and 2:00 am on the days that the
167: reckoning changes.
168: .br
169: Because
170: .IR localtime (2)
171: accepts an old-style time format without zone information, attempting
172: to pass
173: .I getdate
174: a current time containing a different zone will probably fail.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.