Mercurial > emacs
changeset 5882:319a7fcb7609
(difftm): Simplify expression.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 10 Feb 1994 20:27:34 +0000 |
parents | 678a8470e4d1 |
children | 13cb3226cb41 |
files | src/editfns.c |
diffstat | 1 files changed, 15 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/editfns.c Thu Feb 10 09:34:37 1994 +0000 +++ b/src/editfns.c Thu Feb 10 20:27:34 1994 +0000 @@ -611,26 +611,25 @@ /* Yield A - B, measured in seconds. */ static long -difftm(a, b) +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); - return - ( - ( - ( - /* 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 - )*24 + (a->tm_hour - b->tm_hour) - )*60 + (a->tm_min - b->tm_min) - )*60 + (a->tm_sec - b->tm_sec); + /* Some compilers can't handle this as a single return statement. */ + 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)); } DEFUN ("current-time-zone", Fcurrent_time_zone, Scurrent_time_zone, 0, 1, 0,