diff --git a/src/libiso8601/100_leap.c b/src/libiso8601/100_leap.c index 1071a83..3c7349c 100644 --- a/src/libiso8601/100_leap.c +++ b/src/libiso8601/100_leap.c @@ -7,7 +7,7 @@ -static int leap_second_days[] = { +static int leap_second_days_table[] = { 720439, /* 1972-06-30 */ 720623, /* 1972-12-31 */ 720988, /* 1973-12-31 */ @@ -36,12 +36,15 @@ static int leap_second_days[] = { +static int* leap_second_days = leap_second_days_table; +static int leap_second_days_num = sizeof(leap_second_days_table) / sizeof(int); + + + int iso8601_seconds_leap(const struct iso8601_date* date) { - int num_ly = 0, i = 0; - - num_ly = sizeof(leap_second_days) / sizeof(int); - for(i = 0; i < num_ly; ++i) if(leap_second_days[i] == date->day) return 86401; + int i; + for(i = 0; i < leap_second_days_num; ++i) if(leap_second_days[i] == date->day) return 86401; return 86400; } @@ -51,10 +54,10 @@ static int _leap_elapsed_day(int sday, int eday) { int spos, epos; - for(spos = 0; (unsigned)spos < sizeof(leap_second_days) / sizeof(int); ++spos) { + for(spos = 0; spos < leap_second_days_num; ++spos) { if(sday <= leap_second_days[spos]) break; } - for(epos = 0; (unsigned)epos < sizeof(leap_second_days) / sizeof(int); ++epos) { + for(epos = 0; epos < leap_second_days_num; ++epos) { if(eday <= leap_second_days[epos]) break; }