Annotation of 43BSD/contrib/news/man/getdate.3, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.