summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-04-19 02:30:46 +0000
committerJim Meyering <jim@meyering.net>1994-04-19 02:30:46 +0000
commite614cf3cbbb27c13ca1c56c3c925a8ebaa60ccb1 (patch)
treee711c472f800e3e546d4917011554395846f9001 /lib
parentf1e328029666c5018abcfc6eda679b9cb659fea7 (diff)
downloadcoreutils-e614cf3cbbb27c13ca1c56c3c925a8ebaa60ccb1.tar.xz
.
Diffstat (limited to 'lib')
-rw-r--r--lib/getdate.y55
1 files changed, 21 insertions, 34 deletions
diff --git a/lib/getdate.y b/lib/getdate.y
index 63b9e7cfa..f3014fb94 100644
--- a/lib/getdate.y
+++ b/lib/getdate.y
@@ -6,11 +6,11 @@
** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
** send any email to Rich.
**
-** This grammar has nine shift/reduce conflicts.
+** This grammar has 10 shift/reduce conflicts.
**
** This code is in the public domain and has no copyright.
*/
-/* SUPPRESS 287 on yaccpar_sccsid *//* Unusd static variable */
+/* SUPPRESS 287 on yaccpar_sccsid *//* Unused static variable */
/* SUPPRESS 288 on yyerrlab *//* Label unused */
#ifdef HAVE_CONFIG_H
@@ -883,51 +883,38 @@ yylex()
}
}
-
-#define TM_YEAR_ORIGIN 1900
-
-/* Yield A - B, measured in seconds. */
-static long
-difftm (a, b)
- struct tm *a, *b;
-{
- int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
- int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
- int days = (
- /* difference in day of year */
- a->tm_yday - b->tm_yday
- /* + intervening leap days */
- + ((ay >> 2) - (by >> 2))
- - (ay/100 - by/100)
- + ((ay/100 >> 2) - (by/100 >> 2))
- /* + difference in years * 365 */
- + (long)(ay-by) * 365
- );
- return (60*(60*(24*days + (a->tm_hour - b->tm_hour))
- + (a->tm_min - b->tm_min))
- + (a->tm_sec - b->tm_sec));
-}
-
time_t
get_date(p, now)
char *p;
struct timeb *now;
{
- struct tm *tm, gmt;
+ struct tm *tm;
struct timeb ftz;
time_t Start;
time_t tod;
yyInput = p;
- if (now == NULL) {
+ if (now == NULL)
+ {
+ int tz;
+ struct tm *tmp;
+ time_t epoch = 0;
+
now = &ftz;
(void)time(&ftz.time);
- if (! (tm = gmtime (&ftz.time)))
- return -1;
- gmt = *tm; /* Make a copy, in case localtime modifies *tm. */
- ftz.timezone = difftm (&gmt, localtime (&ftz.time)) / 60;
- }
+ /* Compute local timezone. Do *not* take daylight savings
+ into account here. */
+ tmp = localtime (&epoch);
+ tz = tmp->tm_hour * 60 + tmp->tm_min; /* Minutes east of UTC. */
+ if (tz > 0)
+ {
+ tz = 24 * 60 - tz; /* Minutes west of UTC. */
+ if (tmp->tm_year == 70)
+ tz -= 24 * 60; /* Account for date line. */
+ }
+ ftz.timezone = tz;
+ }
tm = localtime(&now->time);
yyYear = tm->tm_year;