diff --git a/src/blog.c b/src/blog.c index eb9086b..61b2c01 100644 --- a/src/blog.c +++ b/src/blog.c @@ -66,7 +66,7 @@ void blog_display() { char *days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "???"}; char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "???"}; char c; - + int hour; int j; int lines = 2; s_printf("\e[2J\e[1;1H"); @@ -98,8 +98,12 @@ void blog_display() { s_printf("\r\n\r\n"); lines = 0; } - - s_printf(get_string(284), (thetime.tm_hour - 12 == 0 ? 12 : thetime.tm_hour - 12), thetime.tm_min, (thetime.tm_hour >= 12 ? "pm" : "am"), days[thetime.tm_wday], months[thetime.tm_mon], thetime.tm_mday, thetime.tm_year + 1900); + if (thetime.tm_hour >= 12) { + hour = thetime.tm_hour - 12; + } else { + hour = thetime.tm_hour; + } + s_printf(get_string(284), (hour == 0 ? 12 : hour), thetime.tm_min, (thetime.tm_hour >= 12 ? "pm" : "am"), days[thetime.tm_wday], months[thetime.tm_mon], thetime.tm_mday, thetime.tm_year + 1900); lines++; if (lines == 22 && tolower(c) != 'c') { diff --git a/src/www_blog.c b/src/www_blog.c index b0a0069..add6462 100644 --- a/src/www_blog.c +++ b/src/www_blog.c @@ -18,7 +18,8 @@ char *www_blog() { int blog_entry_count = 0; int i, j; struct tm thetime; - + int hour; + char *days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "???"}; char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "???"}; @@ -48,7 +49,12 @@ char *www_blog() { } else { for (i=0;idate, &thetime); - sprintf(buffer, "

%s

%d:%02d%s %s, %s %d %d
by %s
", blog_entries[i]->subject,(thetime.tm_hour - 12 == 0 ? 12 : thetime.tm_hour - 12), thetime.tm_min, (thetime.tm_hour >= 12 ? "pm" : "am"), days[thetime.tm_wday], months[thetime.tm_mon], thetime.tm_mday, thetime.tm_year + 1900, blog_entries[i]->author); + if (thetime.tm_hour >= 12) { + hour = thetime.tm_hour - 12; + } else { + hour = thetime.tm_hour; + } + sprintf(buffer, "

%s

%d:%02d%s %s, %s %d %d
by %s
", blog_entries[i]->subject,(hour == 0 ? 12 : hour), thetime.tm_min, (thetime.tm_hour >= 12 ? "pm" : "am"), days[thetime.tm_wday], months[thetime.tm_mon], thetime.tm_mday, thetime.tm_year + 1900, blog_entries[i]->author); if (len + strlen(buffer) > max_len - 1) { max_len += 4096; page = (char *)realloc(page, max_len);