da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/***********************************************************************
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* This software is part of the ast package *
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner* Copyright (c) 1992-2010 AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* and is licensed under the *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Common Public License, Version 1.0 *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin* by AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* A copy of the License is available at *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Information and Software Systems Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* AT&T Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Florham Park NJ *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Glenn Fowler <gsf@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* David Korn <dgk@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin***********************************************************************/
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Glenn Fowler
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * AT&T Research
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * date -- set/display date
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz"[-?\n@(#)$Id: date (AT&T Research) 2009-03-03 $\n]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[+NAME?date - set/list/convert dates]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[+DESCRIPTION?\bdate\b sets the current date and time (with appropriate"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" privilege), lists the current date or file dates, or converts"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[+?Most common \adate\a forms are recognized, including those for"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" \bcrontab\b(1), \bls\b(1), \btouch\b(1), and the default"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" output from \bdate\b itself.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[+?If the \adate\a operand consists of 4, 6, 8, 10 or 12 digits followed"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" by an optional \b.\b and two digits then it is interpreted as:"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" \aHHMM.SS\a, \addHHMM.SS\a, \ammddHHMM.SS\a, \ammddHHMMyy.SS\a or"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" \ayymmddHHMM.SS\a, or \ammddHHMMccyy.SS\a or \accyymmddHHMM.SS\a."
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" Conflicting standards and practice allow a leading or trailing"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" 2 or 4 digit year for the 10 and 12 digit forms; the X/Open trailing"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" form is used to disambiguate (\btouch\b(1) uses the leading form.)"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" Avoid the 10 digit form to avoid confusion. The digit fields are:]{"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+cc?Century - 1, 19-20.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+yy?Year in century, 00-99.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+mm?Month, 01-12.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+dd?Day of month, 01-31.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+HH?Hour, 00-23.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+MM?Minute, 00-59.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+SS?Seconds, 00-60.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[+?If more than one \adate\a operand is specified then:]{"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+1.?Each operand sets the reference date for the next"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" operand.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+2.?The date is listed for each operand.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+3.?The system date is not set.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[a:access-time|atime?List file argument access times.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[c:change-time|ctime?List file argument change times.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[d:date?Use \adate\a as the current date and do not set the system"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" clock.]:[date]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[e:epoch?Output the date in seconds since the epoch."
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" Equivalent to \b--format=%s\b.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[E:elapsed?Interpret pairs of arguments as start and stop dates, sum the"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" differences between all pairs, and list the result as a"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" \bfmtelapsed\b(3) elapsed time on the standard output. If there are"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" an odd number of arguments then the last time argument is differenced"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" with the current time.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[f:format?Output the date according to the \bstrftime\b(3) \aformat\a."
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" For backwards compatibility, a first argument of the form"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" \b+\b\aformat\a is equivalent to \b-f\b format."
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" \aformat\a is in \bprintf\b(3) style, where %\afield\a names"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" a fixed size field, zero padded if necessary,"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" and \\\ac\a and \\\annn\a sequences are as in C. Invalid"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" %\afield\a specifications and all other characters are copied"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" without change. \afield\a may be preceded by \b%-\b to turn off"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" padding or \b%_\b to pad with space, otherwise numeric fields"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" are padded with \b0\b and string fields are padded with space."
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" \afield\a may also be preceded by \bE\b for alternate era"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" representation or \bO\b for alternate digit representation (if"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" supported by the current locale.) Finally, an integral \awidth\a"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" preceding \afield\a truncates the field to \awidth\a characters."
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" The fields are:]:[format]{"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+%?% character]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+a?abbreviated weekday name]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+A?full weekday name]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+b?abbreviated month name]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+c?\bctime\b(3) style date without the trailing newline]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+C?2-digit century]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+d?day of month number]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+D?date as \amm/dd/yy\a]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+e?blank padded day of month number]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+E?unpadded day of month number]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+f?locale default override date format]"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin" [+F?%ISO 8601:2000 standard date format; equivalent to Y-%m-%d]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+g?\bls\b(1) \b-l\b recent date with \ahh:mm\a]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+G?\bls\b(1) \b-l\b distant date with \ayyyy\a]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+h?abbreviated month name]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+H?24-hour clock hour]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+i?international \bdate\b(1) date with time zone type name]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+I?12-hour clock hour]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+j?1-offset Julian date]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+J?0-offset Julian date]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+k?\bdate\b(1) style date]"
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz" [+K?all numeric date; equivalent to \b%Y-%m-%d+%H:%M:%S\b; \b%_[EO]]K\b for space separator, %OK adds \b.%N\b, \b%EK\b adds \b%.N%z\b, \b%_EK\b adds \b.%N %z\b]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+l?\bls\b(1) \b-l\b date; equivalent to \b%Q/%g/%G/\b]"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin" [+L?locale default date format]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+m?month number]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+M?minutes]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+n?newline character]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+N?nanoseconds 000000000-999999999]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+p?meridian (e.g., \bAM\b or \bPM\b)]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+q?time zone type name (nation code)]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+Q?\a<del>recent<del>distant<del>\a: \a<del>\a is a unique"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" delimter character; \arecent\a format for recent"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" dates, \adistant\a format otherwise]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+r?12-hour time as \ahh:mm:ss meridian\a]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+R?24-hour time as \ahh:mm\a]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+s?number of seconds since the epoch; \a.prec\a preceding"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" \bs\b appends \aprec\a nanosecond digits, \b9\b if"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" \aprec\a is omitted]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+S?seconds 00-60]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+t?tab character]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+T?24-hour time as \ahh:mm:ss\a]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+u?weekday number 1(Monday)-7]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+U?week number with Sunday as the first day]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+V?ISO week number (i18n is \afun\a)]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+w?weekday number 0(Sunday)-6]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+W?week number with Monday as the first day]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+x?locale date style that includes month, day and year]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+X?locale time style that includes hours and minutes]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+y?2-digit year (you'll be sorry)]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+Y?4-digit year]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+z?time zone \aSHHMM\a west of GMT offset where S is"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" \b+\b or \b-\b]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+Z?time zone name]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+=[=]][-+]]flag?set (default or +) or clear (-) \aflag\a"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" for the remainder of \aformat\a, or for the remainder"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" of the process if \b==\b is specified. \aflag\a may be:]{"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+l?enable leap second adjustments]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+n?convert \b%S\b as \b%S.%N\b]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+u?UTC time zone]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+#?equivalent to %s]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+??alternate?use \aalternate\a format if a default format"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" override has not been specified, e.g., \bls\b(1) uses"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" \"%?%l\"; export TM_OPTIONS=\"format='\aoverride\a'\""
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" to override the default]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[i:incremental|adjust?Set the system time in incrementatl adjustments to"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" avoid complete time shift shock. Negative adjustments still maintain"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" monotonic increasing time. Not available on all systems.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[L:last?List only the last time for multiple \adate\a operands.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[l:leap-seconds?Include leap seconds in time calculations. Leap seconds"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" after the ast library release date are not accounted for.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[m:modify-time|mtime?List file argument modify times.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[n!:network?Set network time.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[p:parse?Add \aformat\a to the list of \bstrptime\b(3) parse conversion"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" formats. \aformat\a follows the same conventions as the"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" \b--format\b option, with the addition of these format"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" fields:]:[format]{"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+|?If the format failed before this point then restart"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" the parse with the remaining format.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" [+&?Call the \btmdate\b(3) heuristic parser. This is"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" is the default when \b--parse\b is omitted.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[s:show?Show the date without setting the system time.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[u:utc|gmt|zulu?Output dates in \acoordinated universal time\a (UTC).]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[U:unelapsed?Interpret each argument as \bfmtelapsed\b(3) elapsed"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" time and list the \bstrelapsed\b(3) 1/\ascale\a seconds.]#[scale]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[z:list-zones?List the known time zone table and exit. The table columns"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" are: country code, standard zone name, savings time zone name,"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" minutes west of \bUTC\b, and savings time minutes offset. Blank"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" or empty entries are listed as \b-\b.]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"\n[ +format | date ... | file ... ]\n"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"[+SEE ALSO?\bcrontab\b(1), \bls\b(1), \btouch\b(1), \bfmtelapsed\b(3),"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin" \bstrftime\b(3), \bstrptime\b(3), \btm\b(3)]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * set the system clock
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * the standards wimped out here
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinsettime(void* context, const char* cmd, Time_t now, int adjust, int network)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (!streq(cmd, s) && (!eaccess(s, X_OK) || !eaccess(s+=4, X_OK)))
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin tmxfmt(buf, sizeof(buf), "%m%d%H" "%M%Y.%S", now);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin tmxfmt(buf, sizeof(buf), "%Y%m%d%H" "%M.%S", now);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return -1;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * convert s to Time_t with error checking
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (!*t && (!f->format || !*u))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin } while (f = f->next);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (!f || *t)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register int n;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register char* s;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register Fmt_t* f;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin unsigned long u;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin sfprintf(sfstdout, "%3s %4s %4s %4d %4d\n", s, *listzones->standard ? listzones->standard : "-", listzones->daylight ? listzones->daylight : "-", listzones->west, listzones->dst);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin while (s = *argv++)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (!(t = *argv++))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin t = "now";
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin sfputr(sfstdout, fmtelapsed((unsigned long)tmxsec(e), 1), '\n');
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin while (s = *argv++)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin while (s = *argv++)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (s || (s = string))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin } while (s = *++argv);