aboutsummaryrefslogtreecommitdiff
path: root/bin/date/date.c
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2019-03-21 06:47:23 +0000
committerWarner Losh <imp@FreeBSD.org>2019-03-21 06:47:23 +0000
commite77a99c1c15a1d81f9a47c2a7611aa8325662142 (patch)
treec6e442af51490740f2cd568eaff9eed4d1a7af2e /bin/date/date.c
parent1194c3cb5727aeec402eb7421f31869d897e2fcd (diff)
downloadsrc-e77a99c1c15a1d81f9a47c2a7611aa8325662142.tar.gz
src-e77a99c1c15a1d81f9a47c2a7611aa8325662142.zip
Remove -n flag, fix setting date / time
r342139 bork setting the date. This fixes it by simply removing the -n flag. Differential Revision: https://reviews.freebsd.org/D19668
Notes
Notes: svn path=/head/; revision=345365
Diffstat (limited to 'bin/date/date.c')
-rw-r--r--bin/date/date.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/bin/date/date.c b/bin/date/date.c
index 10e8a126d565..7f216e484740 100644
--- a/bin/date/date.c
+++ b/bin/date/date.c
@@ -72,7 +72,7 @@ static void iso8601_usage(const char *);
static void multipleformats(void);
static void printdate(const char *);
static void printisodate(struct tm *);
-static void setthetime(const char *, const char *, int, int);
+static void setthetime(const char *, const char *, int);
static void usage(void);
static const struct iso8601_fmt {
@@ -92,7 +92,7 @@ int
main(int argc, char *argv[])
{
int ch, rflag;
- bool Iflag, jflag, nflag, Rflag;
+ bool Iflag, jflag, Rflag;
const char *format;
char buf[1024];
char *fmt;
@@ -107,8 +107,8 @@ main(int argc, char *argv[])
fmt = NULL;
(void) setlocale(LC_TIME, "");
rflag = 0;
- Iflag = jflag = nflag = Rflag = 0;
- while ((ch = getopt(argc, argv, "f:I::jnRr:uv:")) != -1)
+ Iflag = jflag = Rflag = 0;
+ while ((ch = getopt(argc, argv, "f:I::jRr:uv:")) != -1)
switch((char)ch) {
case 'f':
fmt = optarg;
@@ -132,9 +132,6 @@ main(int argc, char *argv[])
case 'j':
jflag = 1; /* don't set time */
break;
- case 'n': /* don't set network */
- nflag = 1;
- break;
case 'R': /* RFC 2822 datetime format */
if (Iflag)
multipleformats();
@@ -179,7 +176,7 @@ main(int argc, char *argv[])
}
if (*argv) {
- setthetime(fmt, *argv, jflag, nflag);
+ setthetime(fmt, *argv, jflag);
++argv;
} else if (fmt != NULL)
usage();
@@ -250,7 +247,7 @@ printisodate(struct tm *lt)
#define ATOI2(s) ((s) += 2, ((s)[-2] - '0') * 10 + ((s)[-1] - '0'))
static void
-setthetime(const char *fmt, const char *p, int jflag, int nflag)
+setthetime(const char *fmt, const char *p, int jflag)
{
struct utmpx utx;
struct tm *lt;
@@ -343,20 +340,17 @@ setthetime(const char *fmt, const char *p, int jflag, int nflag)
errx(1, "nonexistent time");
if (!jflag) {
- /* set the time */
- if (nflag) {
- utx.ut_type = OLD_TIME;
- memset(utx.ut_id, 0, sizeof(utx.ut_id));
- (void)gettimeofday(&utx.ut_tv, NULL);
- pututxline(&utx);
- tv.tv_sec = tval;
- tv.tv_usec = 0;
- if (settimeofday(&tv, NULL) != 0)
- err(1, "settimeofday (timeval)");
- utx.ut_type = NEW_TIME;
- (void)gettimeofday(&utx.ut_tv, NULL);
- pututxline(&utx);
- }
+ utx.ut_type = OLD_TIME;
+ memset(utx.ut_id, 0, sizeof(utx.ut_id));
+ (void)gettimeofday(&utx.ut_tv, NULL);
+ pututxline(&utx);
+ tv.tv_sec = tval;
+ tv.tv_usec = 0;
+ if (settimeofday(&tv, NULL) != 0)
+ err(1, "settimeofday (timeval)");
+ utx.ut_type = NEW_TIME;
+ (void)gettimeofday(&utx.ut_tv, NULL);
+ pututxline(&utx);
if ((p = getlogin()) == NULL)
p = "???";