diary

Text-based journaling program
git clone https://git.in0rdr.ch/diary.git
Log | Files | Refs | README | LICENSE

commit da8d12a47db3e5772251ec8841cd54dbf436015b
parent c5812c127f7b9f7c1027cc31fb72d2e1b002aa3d
Author: Matthias Beyer <mail@beyermatthias.de>
Date:   Mon, 28 Nov 2016 19:32:49 +0100

Eliminate is_leap() function, replace with macro

Diffstat:
Mdiary.c | 13+++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/diary.c b/diary.c @@ -11,6 +11,11 @@ struct app_state { #define DATE_FMT "%Y-%m-%d" +// normally leap is every 4 years, +// but is skipped every 100 years, +// unless it is divisible by 400 +#define is_leap(yr) ((yr % 400 == 0) || (yr % 4 == 0 && yr % 100 != 0)) + void setup_cal_timeframe(struct app_state* s) { s->raw_time = time(NULL); @@ -215,14 +220,6 @@ bool date_has_entry(char* dir, size_t dir_size, struct tm* i) return (access(epath, F_OK) != -1); } -bool is_leap(int year) -{ - // normally leap is every 4 years, - // but is skipped every 100 years, - // unless it is divisible by 400 - return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0); -} - void get_date_str(struct tm* date, char* date_str, size_t date_str_size) { strftime(date_str, date_str_size, DATE_FMT, date);