Mercurial > blahgd
changeset 72:ade618ba6d5a
feed: fix less-than comparison
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Thu, 09 Apr 2009 22:41:47 -0400 |
parents | a3687513a94b |
children | cda96d801346 |
files | html.c post.h |
diffstat | 2 files changed, 36 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/html.c Thu Apr 09 22:41:33 2009 -0400 +++ b/html.c Thu Apr 09 22:41:47 2009 -0400 @@ -141,12 +141,7 @@ cat(&p, NULL, "templates/story-bottom.atom", NULL); /* copy over the last time? */ - if ((post->lasttime.tm_year < p.time.tm_year) || - (post->lasttime.tm_mon < p.time.tm_mon) || - (post->lasttime.tm_mday < p.time.tm_mday) || - (post->lasttime.tm_hour < p.time.tm_hour) || - (post->lasttime.tm_min < p.time.tm_min) || - (post->lasttime.tm_sec < p.time.tm_sec)) + if (tm_cmp(&post->lasttime, &p.time) < 0) memcpy(&post->lasttime, &p.time, sizeof(struct tm)); destroy_post(&p);
--- a/post.h Thu Apr 09 22:41:33 2009 -0400 +++ b/post.h Thu Apr 09 22:41:47 2009 -0400 @@ -48,4 +48,39 @@ #define max(a,b) ((a)<(b)? (b) : (a)) +static inline int tm_cmp(struct tm *t1, struct tm *t2) +{ + if (t1->tm_year < t2->tm_year) + return -1; + if (t1->tm_year > t2->tm_year) + return 1; + + if (t1->tm_mon < t2->tm_mon) + return -1; + if (t1->tm_mon > t2->tm_mon) + return 1; + + if (t1->tm_mday < t2->tm_mday) + return -1; + if (t1->tm_mday > t2->tm_mday) + return 1; + + if (t1->tm_hour < t2->tm_hour) + return -1; + if (t1->tm_hour > t2->tm_hour) + return 1; + + if (t1->tm_min < t2->tm_min) + return -1; + if (t1->tm_min > t2->tm_min) + return 1; + + if (t1->tm_sec < t2->tm_sec) + return -1; + if (t1->tm_sec > t2->tm_sec) + return 1; + + return 0; +} + #endif