Fix bug in comparison functions, add equality test

This commit is contained in:
Laurence Withers 2007-05-23 13:25:18 +00:00
parent be475c5dc1
commit 728d0b6151
2 changed files with 11 additions and 3 deletions

View File

@ -69,6 +69,7 @@ void iso8601_print(char* str, int amt, const struct iso8601_date* date,
/* manip.c */
int iso8601_lt(const struct iso8601_date* d1, const struct iso8601_date* d2);
int iso8601_lte(const struct iso8601_date* d1, const struct iso8601_date* d2);
int iso8601_eq(const struct iso8601_date* d1, const struct iso8601_date* d2);
void iso8601_add_seconds(struct iso8601_date* date, long seconds);
/* leap.c */

View File

@ -13,8 +13,8 @@ int iso8601_lt(const struct iso8601_date* d1, const struct iso8601_date* d2)
if(d1->day > d2->day) return 0;
if(d1->sec < d2->sec) return 1;
if(d1->sec > d2->sec) return 0;
if(d1->nsec < d2->nsec) return 0;
return 1;
if(d1->nsec < d2->nsec) return 1;
return 0;
}
@ -25,12 +25,19 @@ int iso8601_lte(const struct iso8601_date* d1, const struct iso8601_date* d2)
if(d1->day > d2->day) return 0;
if(d1->sec < d2->sec) return 1;
if(d1->sec > d2->sec) return 0;
if(d1->nsec < d2->nsec) return 0;
if(d1->nsec < d2->nsec) return 1;
return d1->nsec == d2->nsec;
}
int iso8601_eq(const struct iso8601_date* d1, const struct iso8601_date* d2)
{
return (d1->day == d2->day) && (d1->sec == d2->sec) && (d1->nsec == d2->nsec);
}
void iso8601_add_seconds(struct iso8601_date* date, long seconds)
{
int sday;