MFC r282608:
date(1): Make -r behave like GNU's version when the option can not be interpreted as a number, which checks the file's modification time and use that as the date/time value. This improves compatibility with GNU coreutils's version of date(1).
This commit is contained in:
parent
6ce5eda96c
commit
f14ca7e990
@ -32,7 +32,7 @@
|
|||||||
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
|
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd April 26, 2014
|
.Dd May 7, 2015
|
||||||
.Dt DATE 1
|
.Dt DATE 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -41,7 +41,7 @@
|
|||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl jRu
|
.Op Fl jRu
|
||||||
.Op Fl r Ar seconds
|
.Op Fl r Ar seconds | Ar filename
|
||||||
.Oo
|
.Oo
|
||||||
.Fl v
|
.Fl v
|
||||||
.Sm off
|
.Sm off
|
||||||
@ -150,6 +150,9 @@ is the number of seconds since the Epoch
|
|||||||
see
|
see
|
||||||
.Xr time 3 ) ,
|
.Xr time 3 ) ,
|
||||||
and can be specified in decimal, octal, or hex.
|
and can be specified in decimal, octal, or hex.
|
||||||
|
.It Fl r Ar filename
|
||||||
|
Print the date and time of the last modification of
|
||||||
|
.Ar filename .
|
||||||
.It Fl t Ar minutes_west
|
.It Fl t Ar minutes_west
|
||||||
Set the system's value for minutes west of
|
Set the system's value for minutes west of
|
||||||
.Tn GMT .
|
.Tn GMT .
|
||||||
|
@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
@ -85,6 +86,7 @@ main(int argc, char *argv[])
|
|||||||
struct vary *v;
|
struct vary *v;
|
||||||
const struct vary *badv;
|
const struct vary *badv;
|
||||||
struct tm lt;
|
struct tm lt;
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
v = NULL;
|
v = NULL;
|
||||||
fmt = NULL;
|
fmt = NULL;
|
||||||
@ -116,8 +118,12 @@ main(int argc, char *argv[])
|
|||||||
case 'r': /* user specified seconds */
|
case 'r': /* user specified seconds */
|
||||||
rflag = 1;
|
rflag = 1;
|
||||||
tval = strtoq(optarg, &tmp, 0);
|
tval = strtoq(optarg, &tmp, 0);
|
||||||
if (*tmp != 0)
|
if (*tmp != 0) {
|
||||||
usage();
|
if (stat(optarg, &sb) == 0)
|
||||||
|
tval = sb.st_mtim.tv_sec;
|
||||||
|
else
|
||||||
|
usage();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 't': /* minutes west of UTC */
|
case 't': /* minutes west of UTC */
|
||||||
/* error check; don't allow "PST" */
|
/* error check; don't allow "PST" */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user