diff options
| author | Karl Heuer | 1994-02-10 20:27:34 +0000 |
|---|---|---|
| committer | Karl Heuer | 1994-02-10 20:27:34 +0000 |
| commit | 8e718b4eb6fd3cfc5e7a077b89da9a24682e2019 (patch) | |
| tree | eefffc776987129f04ffb2a95647600beca72172 /src/editfns.c | |
| parent | 9106ccf1ff325f95bb2c950f4cc5b6617acde1eb (diff) | |
| download | emacs-8e718b4eb6fd3cfc5e7a077b89da9a24682e2019.tar.gz emacs-8e718b4eb6fd3cfc5e7a077b89da9a24682e2019.zip | |
(difftm): Simplify expression.
Diffstat (limited to 'src/editfns.c')
| -rw-r--r-- | src/editfns.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/editfns.c b/src/editfns.c index 8983aa4aea4..e6fcbfdf35d 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -611,26 +611,25 @@ and from `file-attributes'.") | |||
| 611 | 611 | ||
| 612 | /* Yield A - B, measured in seconds. */ | 612 | /* Yield A - B, measured in seconds. */ |
| 613 | static long | 613 | static long |
| 614 | difftm(a, b) | 614 | difftm (a, b) |
| 615 | struct tm *a, *b; | 615 | struct tm *a, *b; |
| 616 | { | 616 | { |
| 617 | int ay = a->tm_year + (TM_YEAR_ORIGIN - 1); | 617 | int ay = a->tm_year + (TM_YEAR_ORIGIN - 1); |
| 618 | int by = b->tm_year + (TM_YEAR_ORIGIN - 1); | 618 | int by = b->tm_year + (TM_YEAR_ORIGIN - 1); |
| 619 | return | 619 | /* Some compilers can't handle this as a single return statement. */ |
| 620 | ( | 620 | int days = ( |
| 621 | ( | 621 | /* difference in day of year */ |
| 622 | ( | 622 | a->tm_yday - b->tm_yday |
| 623 | /* difference in day of year */ | 623 | /* + intervening leap days */ |
| 624 | a->tm_yday - b->tm_yday | 624 | + ((ay >> 2) - (by >> 2)) |
| 625 | /* + intervening leap days */ | 625 | - (ay/100 - by/100) |
| 626 | + ((ay >> 2) - (by >> 2)) | 626 | + ((ay/100 >> 2) - (by/100 >> 2)) |
| 627 | - (ay/100 - by/100) | 627 | /* + difference in years * 365 */ |
| 628 | + ((ay/100 >> 2) - (by/100 >> 2)) | 628 | + (long)(ay-by) * 365 |
| 629 | /* + difference in years * 365 */ | 629 | ); |
| 630 | + (long)(ay-by) * 365 | 630 | return (60*(60*(24*days + (a->tm_hour - b->tm_hour)) |
| 631 | )*24 + (a->tm_hour - b->tm_hour) | 631 | + (a->tm_min - b->tm_min)) |
| 632 | )*60 + (a->tm_min - b->tm_min) | 632 | + (a->tm_sec - b->tm_sec)); |
| 633 | )*60 + (a->tm_sec - b->tm_sec); | ||
| 634 | } | 633 | } |
| 635 | 634 | ||
| 636 | DEFUN ("current-time-zone", Fcurrent_time_zone, Scurrent_time_zone, 0, 1, 0, | 635 | DEFUN ("current-time-zone", Fcurrent_time_zone, Scurrent_time_zone, 0, 1, 0, |