diff --git a/bin/date/date.1 b/bin/date/date.1 index d1cbb44..b75c67a 100644 --- a/bin/date/date.1 +++ b/bin/date/date.1 @@ -130,6 +130,11 @@ The .Fl n option suppresses this behavior and causes the time to be set only on the current machine. +.It Fl R +Use RFC 2822 date and time output format. This is equivalent to use +.Dq Li %a, %d %b %Y \&%T %z +as +.Ar output_fmt . .It Fl r Ar seconds Print the date and time represented by .Ar seconds , diff --git a/bin/date/date.c b/bin/date/date.c index 58a9afb..031ebed 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -74,7 +74,7 @@ main(int argc, char *argv[]) { struct timezone tz; int ch, rflag; - int jflag, nflag; + int jflag, nflag, Rflag; const char *format; char buf[1024]; char *endptr, *fmt; @@ -89,9 +89,9 @@ main(int argc, char *argv[]) (void) setlocale(LC_TIME, ""); tz.tz_dsttime = tz.tz_minuteswest = 0; rflag = 0; - jflag = nflag = 0; + jflag = nflag = Rflag = 0; set_timezone = 0; - while ((ch = getopt(argc, argv, "d:f:jnr:t:uv:")) != -1) + while ((ch = getopt(argc, argv, "d:f:jnRr:t:uv:")) != -1) switch((char)ch) { case 'd': /* daylight savings time */ tz.tz_dsttime = strtol(optarg, &endptr, 10) ? 1 : 0; @@ -108,6 +108,9 @@ main(int argc, char *argv[]) case 'n': /* don't set network */ nflag = 1; break; + case 'R': /* RFC 2822 datetime format */ + Rflag = 1; + break; case 'r': /* user specified seconds */ rflag = 1; tval = strtoq(optarg, &tmp, 0); @@ -145,6 +148,9 @@ main(int argc, char *argv[]) format = "%+"; + if (Rflag) + format = "%a, %d %b %Y %T %z"; + /* allow the operands in any order */ if (*argv && **argv == '+') { format = *argv + 1; @@ -301,7 +307,7 @@ static void usage(void) { (void)fprintf(stderr, "%s\n%s\n", - "usage: date [-jnu] [-d dst] [-r seconds] [-t west] " + "usage: date [-jnRu] [-d dst] [-r seconds] [-t west] " "[-v[+|-]val[ymwdHMS]] ... ", " " "[-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]");