summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2015-03-17 19:31:31 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2015-03-17 19:31:31 +0000
commitd89b46203d7381d858c629ed0767ba4bd4d51d71 (patch)
treed5cd36ddd500affa3091099368ca03de3bf9551d
parentc5e441df5c5de5c985fa199fa7995a4e383875b4 (diff)
Eliminate use of TM_YEAR_BASE. OK guenther@ deraadt@ miod@
-rw-r--r--bin/date/date.c4
-rw-r--r--games/pom/pom.c10
-rw-r--r--include/time.h7
-rw-r--r--libexec/ftpd/ftpcmd.y4
-rw-r--r--usr.bin/at/parsetime.c8
-rw-r--r--usr.bin/cal/cal.c6
-rw-r--r--usr.bin/calendar/day.c25
-rw-r--r--usr.bin/ftp/util.c4
-rw-r--r--usr.bin/touch/touch.c8
9 files changed, 34 insertions, 42 deletions
diff --git a/bin/date/date.c b/bin/date/date.c
index 5156117d2a4..8c39ac08bfd 100644
--- a/bin/date/date.c
+++ b/bin/date/date.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: date.c,v 1.45 2015/03/15 00:41:27 millert Exp $ */
+/* $OpenBSD: date.c,v 1.46 2015/03/17 19:31:30 millert Exp $ */
/* $NetBSD: date.c,v 1.11 1995/09/07 06:21:05 jtc Exp $ */
/*
@@ -182,7 +182,7 @@ setthetime(char *p)
switch (strlen(p)) {
case 12: /* cc */
- lt->tm_year = ATOI2(p) * 100 - TM_YEAR_BASE;
+ lt->tm_year = (ATOI2(p) * 100) - 1900;
yearset = 1;
/* FALLTHROUGH */
case 10: /* yy */
diff --git a/games/pom/pom.c b/games/pom/pom.c
index 531f2806fa5..f36d8036fa5 100644
--- a/games/pom/pom.c
+++ b/games/pom/pom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pom.c,v 1.15 2015/03/15 00:41:27 millert Exp $ */
+/* $OpenBSD: pom.c,v 1.16 2015/03/17 19:31:30 millert Exp $ */
/* $NetBSD: pom.c,v 1.6 1996/02/06 22:47:29 jtc Exp $ */
/*
@@ -99,10 +99,10 @@ main(int argc, char *argv[])
days = (GMT->tm_yday + 1) + ((GMT->tm_hour +
(GMT->tm_min / 60.0) + (GMT->tm_sec / 3600.0)) / 24.0);
for (cnt = EPOCH; cnt < GMT->tm_year; ++cnt)
- days += isleap(cnt + TM_YEAR_BASE) ? 366 : 365;
+ days += isleap(cnt + 1900) ? 366 : 365;
/* Selected time could be before EPOCH */
for (cnt = GMT->tm_year; cnt < EPOCH; ++cnt)
- days -= isleap(cnt + TM_YEAR_BASE) ? 366 : 365;
+ days -= isleap(cnt + 1900) ? 366 : 365;
today = potm(days) + 0.5;
(void)printf("The Moon is ");
if ((int)today == 100)
@@ -218,14 +218,14 @@ parsetime(char *p)
switch (strlen(p)) {
case 10: /* yyyy */
bigyear = ATOI2(p);
- lt->tm_year = bigyear * 100 - TM_YEAR_BASE;
+ lt->tm_year = (bigyear * 100) - 1900;
yearset = 1;
/* FALLTHROUGH */
case 8: /* yy */
if (yearset) {
lt->tm_year += ATOI2(p);
} else {
- lt->tm_year = ATOI2(p) + 1900 - TM_YEAR_BASE;
+ lt->tm_year = ATOI2(p);
if (lt->tm_year < 69) /* hack for 2000 */
lt->tm_year += 100;
}
diff --git a/include/time.h b/include/time.h
index 02b35575371..a48321a7a9e 100644
--- a/include/time.h
+++ b/include/time.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: time.h,v 1.26 2015/03/15 00:41:27 millert Exp $ */
+/* $OpenBSD: time.h,v 1.27 2015/03/17 19:31:30 millert Exp $ */
/* $NetBSD: time.h,v 1.9 1994/10/26 00:56:35 cgd Exp $ */
/*
@@ -166,11 +166,6 @@ int clock_getcpuclockid(pid_t, clockid_t *);
#endif
#if __BSD_VISIBLE
-
-#ifndef TM_YEAR_BASE
-#define TM_YEAR_BASE 1900
-#endif
-
char *timezone(int, int);
void tzsetwall(void);
time_t timelocal(struct tm *);
diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y
index 36e79b2b536..a853b9b3ff0 100644
--- a/libexec/ftpd/ftpcmd.y
+++ b/libexec/ftpd/ftpcmd.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftpcmd.y,v 1.58 2015/03/15 00:41:27 millert Exp $ */
+/* $OpenBSD: ftpcmd.y,v 1.59 2015/03/17 19:31:30 millert Exp $ */
/* $NetBSD: ftpcmd.y,v 1.7 1996/04/08 19:03:11 jtc Exp $ */
/*
@@ -624,7 +624,7 @@ cmd
t = gmtime(&stbuf.st_mtime);
reply(213,
"%04d%02d%02d%02d%02d%02d",
- TM_YEAR_BASE + t->tm_year,
+ 1900 + t->tm_year,
t->tm_mon+1, t->tm_mday,
t->tm_hour, t->tm_min, t->tm_sec);
}
diff --git a/usr.bin/at/parsetime.c b/usr.bin/at/parsetime.c
index e95813e8dec..452a548283a 100644
--- a/usr.bin/at/parsetime.c
+++ b/usr.bin/at/parsetime.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parsetime.c,v 1.21 2015/03/15 00:41:27 millert Exp $ */
+/* $OpenBSD: parsetime.c,v 1.22 2015/03/17 19:31:30 millert Exp $ */
/*
* parsetime.c - parse time for at(1)
@@ -463,8 +463,8 @@ assign_date(struct tm *tm, int mday, int mon, int year)
* We may be given the year in 2 digit, 4 digit, or tm_year format.
*/
if (year != -1) {
- if (year >= TM_YEAR_BASE)
- year -= TM_YEAR_BASE; /* convert from 4 digit year */
+ if (year >= 1900)
+ year -= 1900; /* convert from 4 digit year */
else if (year < 100) {
/* Convert to tm_year assuming current century */
year += (tm->tm_year / 100) * 100;
@@ -587,7 +587,7 @@ month(struct tm *tm)
}
} else if (tlen == 6 || tlen == 8) {
if (tlen == 8) {
- year = (mon % 10000) - TM_YEAR_BASE;
+ year = (mon % 10000) - 1900;
mon /= 10000;
} else {
year = mon % 100;
diff --git a/usr.bin/cal/cal.c b/usr.bin/cal/cal.c
index df7a02620c8..144b8635d21 100644
--- a/usr.bin/cal/cal.c
+++ b/usr.bin/cal/cal.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cal.c,v 1.27 2015/03/15 00:41:27 millert Exp $ */
+/* $OpenBSD: cal.c,v 1.28 2015/03/17 19:31:30 millert Exp $ */
/* $NetBSD: cal.c,v 1.6 1995/03/26 03:10:24 glass Exp $ */
/*
@@ -202,7 +202,7 @@ main(int argc, char *argv[])
errx(1, "illegal year value: use 1-9999");
(void)time(&now);
local_time = localtime(&now);
- year = local_time->tm_year + TM_YEAR_BASE;
+ year = local_time->tm_year + 1900;
} else {
year = strtonum(*argv, 1, 9999, &errstr);
if (errstr)
@@ -212,7 +212,7 @@ main(int argc, char *argv[])
case 0:
(void)time(&now);
local_time = localtime(&now);
- year = local_time->tm_year + TM_YEAR_BASE;
+ year = local_time->tm_year + 1900;
if (!yflag)
month = local_time->tm_mon + 1;
break;
diff --git a/usr.bin/calendar/day.c b/usr.bin/calendar/day.c
index ab8308e4f68..703be4d8cc6 100644
--- a/usr.bin/calendar/day.c
+++ b/usr.bin/calendar/day.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: day.c,v 1.28 2015/03/15 00:41:28 millert Exp $ */
+/* $OpenBSD: day.c,v 1.29 2015/03/17 19:31:30 millert Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -156,7 +156,7 @@ settime(time_t *now)
tp->tm_isdst = 0;
tp->tm_hour = 12;
*now = mktime(tp);
- if (isleap(tp->tm_year + TM_YEAR_BASE))
+ if (isleap(tp->tm_year + 1900))
cumdays = daytab[1];
else
cumdays = daytab[0];
@@ -214,13 +214,10 @@ Mktime(char *date)
*(date + len - 4) = '\0';
tm.tm_year = atoi(date);
- /* tm_year up TM_YEAR_BASE ... */
if (tm.tm_year < 69) /* Y2K */
- tm.tm_year += 2000 - TM_YEAR_BASE;
- else if (tm.tm_year < 100)
- tm.tm_year += 1900 - TM_YEAR_BASE;
- else if (tm.tm_year > TM_YEAR_BASE)
- tm.tm_year -= TM_YEAR_BASE;
+ tm.tm_year += 100;
+ else if (tm.tm_year > 1900)
+ tm.tm_year -= 1900;
}
#if DEBUG
@@ -430,16 +427,16 @@ isnow(char *endp, int bodun)
*/
if (tp->tm_yday > 300 && tmtmp.tm_mon <= 1)
variable_weekday(&vwd, tmtmp.tm_mon + 1,
- tmtmp.tm_year + TM_YEAR_BASE + 1);
+ tmtmp.tm_year + 1900 + 1);
else
variable_weekday(&vwd, tmtmp.tm_mon + 1,
- tmtmp.tm_year + TM_YEAR_BASE);
+ tmtmp.tm_year + 1900);
day = cumdays[tmtmp.tm_mon + 1] + vwd;
tmtmp.tm_mday = vwd;
}
v2 = day - tp->tm_yday;
if ((v2 > v1) || (v2 < 0)) {
- if ((v2 += isleap(tp->tm_year + TM_YEAR_BASE) ? 366 : 365)
+ if ((v2 += isleap(tp->tm_year + 1900) ? 366 : 365)
<= v1)
tmtmp.tm_year++;
else if(!bodun || (day - tp->tm_yday) != -1)
@@ -515,7 +512,7 @@ isnow(char *endp, int bodun)
if (vwd) {
v1 = vwd;
variable_weekday(&v1, tmtmp.tm_mon + 1,
- tmtmp.tm_year + TM_YEAR_BASE);
+ tmtmp.tm_year + 1900);
tmtmp.tm_mday = v1;
} else
tmtmp.tm_mday = dayp;
@@ -526,11 +523,11 @@ isnow(char *endp, int bodun)
if (flags & F_SPECIAL) {
tmtmp.tm_mon = 0; /* Gee, mktime() is nice */
tmtmp.tm_mday = spev[v1].getev(tmtmp.tm_year +
- TM_YEAR_BASE) + vwd;
+ 1900) + vwd;
} else if (vwd) {
v1 = vwd;
variable_weekday(&v1, tmtmp.tm_mon + 1,
- tmtmp.tm_year + TM_YEAR_BASE);
+ tmtmp.tm_year + 1900);
tmtmp.tm_mday = v1;
} else {
/* Need the following to keep Feb 29 from
diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c
index 2013c8aff65..984bf71beda 100644
--- a/usr.bin/ftp/util.c
+++ b/usr.bin/ftp/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.71 2015/03/15 00:41:28 millert Exp $ */
+/* $OpenBSD: util.c,v 1.72 2015/03/17 19:31:30 millert Exp $ */
/* $NetBSD: util.c,v 1.12 1997/08/18 10:20:27 lukem Exp $ */
/*-
@@ -645,7 +645,7 @@ remotemodtime(const char *file, int noisy)
timebuf.tm_hour = hour;
timebuf.tm_mday = day;
timebuf.tm_mon = mo - 1;
- timebuf.tm_year = yy - TM_YEAR_BASE;
+ timebuf.tm_year = yy - 1900;
timebuf.tm_isdst = -1;
rtime = mktime(&timebuf);
if (rtime == -1 && (noisy
diff --git a/usr.bin/touch/touch.c b/usr.bin/touch/touch.c
index a108a055963..d3b14d6d00a 100644
--- a/usr.bin/touch/touch.c
+++ b/usr.bin/touch/touch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: touch.c,v 1.22 2015/03/15 00:41:28 millert Exp $ */
+/* $OpenBSD: touch.c,v 1.23 2015/03/17 19:31:30 millert Exp $ */
/* $NetBSD: touch.c,v 1.11 1995/08/31 22:10:06 jtc Exp $ */
/*
@@ -179,7 +179,7 @@ stime_arg1(char *arg, struct timespec *tsp)
yearset = 0;
switch (strlen(arg)) {
case 12: /* CCYYMMDDhhmm */
- lt->tm_year = ATOI2(arg) * 100 - TM_YEAR_BASE;
+ lt->tm_year = (ATOI2(arg) * 100) - 1900;
yearset = 1;
/* FALLTHROUGH */
case 10: /* YYMMDDhhmm */
@@ -189,7 +189,7 @@ stime_arg1(char *arg, struct timespec *tsp)
} else {
yearset = ATOI2(arg);
/* POSIX logic: [00,68]=>20xx, [69,99]=>19xx */
- lt->tm_year = yearset + 1900 - TM_YEAR_BASE;
+ lt->tm_year = yearset;
if (yearset < 69)
lt->tm_year += 100;
}
@@ -248,7 +248,7 @@ stime_arg2(char *arg, int year, struct timespec *tsp)
if (year) {
year = ATOI2(arg);
/* POSIX logic: [00,68]=>20xx, [69,99]=>19xx */
- lt->tm_year = year + 1900 - TM_YEAR_BASE;
+ lt->tm_year = year;
if (year < 69)
lt->tm_year += 100;
}