Use upper case for macro names.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
b9fa5bdbb1
commit
d6e5347340
@ -55,7 +55,7 @@
|
||||
#define Pzero 36.340410 /* lunar mean long of perigee at EPOCH */
|
||||
#define Nzero 318.510107 /* lunar mean long of node at EPOCH */
|
||||
|
||||
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
|
||||
#define ISLEAP(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
|
||||
|
||||
enum {
|
||||
CAL_MONTH_VIEW,
|
||||
@ -263,7 +263,7 @@ ymd_to_scalar (unsigned year, unsigned month, unsigned day)
|
||||
|
||||
scalar = day + months_to_days (month);
|
||||
if (month > 2)
|
||||
scalar -= isleap (year) ? 1 : 2;
|
||||
scalar -= ISLEAP (year) ? 1 : 2;
|
||||
year--;
|
||||
scalar += years_to_days (year);
|
||||
|
||||
@ -315,7 +315,7 @@ draw_monthly_view (struct window *cwin, struct date *current_day,
|
||||
|
||||
/* checking the number of days in february */
|
||||
numdays = days[mo - 1];
|
||||
if (2 == mo && isleap (yr))
|
||||
if (2 == mo && ISLEAP (yr))
|
||||
++numdays;
|
||||
|
||||
/*
|
||||
@ -451,7 +451,7 @@ ISO8601weeknum (const struct tm *t)
|
||||
dec31ly.tm_mon = 11;
|
||||
dec31ly.tm_mday = 31;
|
||||
dec31ly.tm_wday = (jan1day == SUNDAY) ? 6 : jan1day - 1;
|
||||
dec31ly.tm_yday = 364 + isleap (dec31ly.tm_year + 1900);
|
||||
dec31ly.tm_yday = 364 + ISLEAP (dec31ly.tm_year + 1900);
|
||||
wnum = ISO8601weeknum (&dec31ly);
|
||||
}
|
||||
break;
|
||||
@ -893,10 +893,10 @@ pom (time_t tmpt)
|
||||
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 + TM_YEAR_BASE) ? 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 + TM_YEAR_BASE) ? 366 : 365;
|
||||
|
||||
return (potm (days));
|
||||
}
|
||||
|
@ -588,12 +588,12 @@ recur_save_data (FILE *f)
|
||||
* diff_months and diff_years functions were provided by Lukas Fleischer to
|
||||
* correct the wrong calculation of recurrent dates after a turn of year.
|
||||
*/
|
||||
#define bc(start, end, bs) \
|
||||
#define BC(start, end, bs) \
|
||||
(((end) - (start) + ((start) % bs) - ((end) % bs)) / bs \
|
||||
+ ((((start) % bs) == 0) ? 1 : 0))
|
||||
|
||||
#define leapcount(start, end) \
|
||||
(bc(start, end, 4) - bc(start, end, 100) + bc(start, end, 400))
|
||||
#define LEAPCOUNT(start, end) \
|
||||
(BC(start, end, 4) - BC(start, end, 100) + BC(start, end, 400))
|
||||
|
||||
|
||||
/* Calculate the difference in days between two dates. */
|
||||
@ -610,7 +610,7 @@ diff_days (struct tm lt_start, struct tm lt_end)
|
||||
if (lt_end.tm_year > lt_start.tm_year)
|
||||
{
|
||||
diff += (lt_end.tm_year - lt_start.tm_year) * YEARINDAYS;
|
||||
diff += leapcount (lt_start.tm_year + TM_YEAR_BASE,
|
||||
diff += LEAPCOUNT (lt_start.tm_year + TM_YEAR_BASE,
|
||||
lt_end.tm_year + TM_YEAR_BASE - 1);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
||||
|
||||
#include "calcurse.h"
|
||||
|
||||
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
|
||||
#define ISLEAP(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
|
||||
|
||||
/* General routine to exit calcurse properly. */
|
||||
void
|
||||
@ -825,7 +825,7 @@ parse_date (char *date_string, enum datefmt datefmt, int *year, int *month,
|
||||
|
||||
/* check if date is valid, take leap years into account */
|
||||
if (y < 1902 || y > 2037 || m < 1 || m > 12 || d < 1 ||
|
||||
d > days[m - 1] + (m == 2 && isleap (y)) ? 1 : 0)
|
||||
d > days[m - 1] + (m == 2 && ISLEAP (y)) ? 1 : 0)
|
||||
return 0;
|
||||
|
||||
if (year) *year = y;
|
||||
|
Loading…
x
Reference in New Issue
Block a user