Add -d option, similar to gnu date.
This commit is contained in:
parent
cbaf7914e4
commit
aa62ece776
@ -1,8 +1,8 @@
|
||||
# $NetBSD: Makefile,v 1.11 2003/07/18 02:18:57 lukem Exp $
|
||||
# $NetBSD: Makefile,v 1.12 2006/11/15 16:55:18 christos Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
|
||||
PROG= date
|
||||
SRCS= date.c netdate.c
|
||||
SRCS= date.c netdate.c getdate.y
|
||||
DPADD+= ${LIBUTIL}
|
||||
LDADD+= -lutil
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: date.1,v 1.35 2006/11/15 03:10:01 jdarrow Exp $
|
||||
.\" $NetBSD: date.1,v 1.36 2006/11/15 16:55:18 christos Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1980, 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -32,7 +32,7 @@
|
||||
.\"
|
||||
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
|
||||
.\"
|
||||
.Dd April 18, 2005
|
||||
.Dd November 15, 2006
|
||||
.Dt DATE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -41,6 +41,7 @@
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl ajnu
|
||||
.Op Fl d Ar date
|
||||
.Op Fl r Ar seconds
|
||||
.Op Cm + Ns Ar format
|
||||
.Sm off
|
||||
@ -69,9 +70,12 @@ maintaining it as a monotonically increasing function.
|
||||
.Fl a
|
||||
implies
|
||||
.Fl n .
|
||||
.It Fl j
|
||||
Parse the provided date and time and display the result without
|
||||
.It Fl d Ar date
|
||||
Parse the provided human-described date and time and display the result without
|
||||
actually changing the system clock.
|
||||
.It Fl j
|
||||
Parse the provided canonical representation of date and time (described below)
|
||||
and display the result without actually changing the system clock.
|
||||
.It Fl n
|
||||
The utility
|
||||
.Xr timed 8
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: date.c,v 1.46 2006/11/15 03:10:01 jdarrow Exp $ */
|
||||
/* $NetBSD: date.c,v 1.47 2006/11/15 16:55:18 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985, 1987, 1988, 1993
|
||||
@ -40,7 +40,7 @@ __COPYRIGHT(
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)date.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: date.c,v 1.46 2006/11/15 03:10:01 jdarrow Exp $");
|
||||
__RCSID("$NetBSD: date.c,v 1.47 2006/11/15 16:55:18 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -83,12 +83,18 @@ main(int argc, char *argv[])
|
||||
setprogname(argv[0]);
|
||||
(void)setlocale(LC_ALL, "");
|
||||
|
||||
while ((ch = getopt(argc, argv, "ajnr:u")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "ad:jnr:u")) != -1) {
|
||||
switch (ch) {
|
||||
case 'a': /* adjust time slowly */
|
||||
aflag = 1;
|
||||
nflag = 1;
|
||||
break;
|
||||
case 'd':
|
||||
rflag = 1;
|
||||
tval = get_date(optarg, NULL, NULL);
|
||||
if (tval == -1)
|
||||
errx(1, "Cannot parse `%s'", optarg);
|
||||
break;
|
||||
case 'j': /* don't set time */
|
||||
jflag = 1;
|
||||
break;
|
||||
@ -310,7 +316,7 @@ static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: %s [-ajnu] [-r seconds] [+format]", getprogname());
|
||||
"usage: %s [-ajnu] [-d date] [-r seconds] [+format]", getprogname());
|
||||
(void)fprintf(stderr, " [[[[[[CC]yy]mm]dd]HH]MM[.SS]]\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* NOTREACHED */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.5 2003/08/07 09:05:09 agc Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.6 2006/11/15 16:55:18 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
@ -35,5 +35,6 @@
|
||||
#define _EXTERN_H_
|
||||
|
||||
int netsettime(time_t);
|
||||
time_t get_date(const char *p, time_t *now, int *zone);
|
||||
|
||||
#endif /* !_EXTERN_H_ */
|
||||
|
1014
bin/date/getdate.y
Normal file
1014
bin/date/getdate.y
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user