From: Jaakko Heinonen Date: Sat, 26 Aug 2006 18:17:14 +0000 (+0000) Subject: * clean up ISO 8601 string generation X-Git-Tag: upstream/0.6.1~2^2~101 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=31c284414c6effcd85add7a7b19d4464ee0e3625;p=pkg%2Fabook.git * clean up ISO 8601 string generation * atoi() -> safe_atoi() --- diff --git a/TODO b/TODO index e04c561..c13e549 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,3 @@ -0.6 - - input for day type should be implemented - generic: - grouping - new file format (xml?) diff --git a/edit.c b/edit.c index a08fdc9..ef956ef 100644 --- a/edit.c +++ b/edit.c @@ -251,9 +251,12 @@ editor_print_data(int tab, int item) strncpy(buf, str, sizeof(buf)); if(str && parse_date_string(buf, &day, &month, &year)) { - str = strdup_printf(year ? " %04d-%02d-%02d" : - "%c%02d-%02d", year ? year : ' ', - month, day); + if(year) + str = strdup_printf("%04d-%02d-%02d", + year, month, day); + else + str = strdup_printf("--%02d-%02d", + month, day); mvwaddnstr(editw, y, TAB_COLON_POS + 2, str, bytes2width(str, FIELD_MAX_WIDTH)); free(str); @@ -440,8 +443,8 @@ parse_date_string(char *s, int *day, int *month, int *year) return FALSE; *s++ = '\0'; switch(i) { - case 1: *year = atoi(p); break; - case 2: *month = atoi(p); break; + case 1: *year = safe_atoi(p); break; + case 2: *month = safe_atoi(p); break; } p = s; } else