summaryrefslogtreecommitdiffstats
path: root/lib/parse-date.y
diff options
context:
space:
mode:
authorJ William Piggott2017-06-07 19:25:43 +0200
committerJ William Piggott2017-06-15 21:02:58 +0200
commit1d6702edfd7fd16d326fae7d8207d17d93d336ee (patch)
tree2b4e78859dee4c192abb82f33060df0db6681f6f /lib/parse-date.y
parentparse-date: use to_uchar() instead of assignment. (diff)
downloadkernel-qcow2-util-linux-1d6702edfd7fd16d326fae7d8207d17d93d336ee.tar.gz
kernel-qcow2-util-linux-1d6702edfd7fd16d326fae7d8207d17d93d336ee.tar.xz
kernel-qcow2-util-linux-1d6702edfd7fd16d326fae7d8207d17d93d336ee.zip
parse-date: refactor tm_diff()
Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl> Influenced-by: gnulib 30784c4 Paul Eggert <eggert@cs.ucla.edu> Signed-off-by: J William Piggott <elseifthen@gmx.com>
Diffstat (limited to 'lib/parse-date.y')
-rw-r--r--lib/parse-date.y5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/parse-date.y b/lib/parse-date.y
index 620626e29..f96fc0928 100644
--- a/lib/parse-date.y
+++ b/lib/parse-date.y
@@ -957,7 +957,7 @@ static table const * lookup_zone(parser_control const *pc, char const *name)
* The body of this function is taken directly from the GNU C Library;
* see src/strftime.c.
*/
-static long int tm_diff(struct tm const *a, struct tm const *b)
+static int tm_diff(struct tm const *a, struct tm const *b)
{
/**
* Compute intervening leap days correctly even if year is negative.
@@ -970,8 +970,7 @@ static long int tm_diff(struct tm const *a, struct tm const *b)
int a400 = SHR (a100, 2);
int b400 = SHR (b100, 2);
int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
- int ayear = a->tm_year;
- int years = ayear - b->tm_year;
+ int years = a->tm_year - b->tm_year;
int days = (365 * years + intervening_leap_days
+ (a->tm_yday - b->tm_yday));
return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))