diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2006-05-04 14:35:06 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2006-05-04 14:35:06 +0800 |
commit | 0764d07f9886b2645b6649201495762adc5af96e (patch) | |
tree | 488b19ba172f2ecbdfb5f57e4c6b130fc94393b9 /mbbsd/calendar.c | |
parent | d146af9094828a4a0acf6a3da40d7401808e95e6 (diff) | |
download | pttbbs-0764d07f9886b2645b6649201495762adc5af96e.tar pttbbs-0764d07f9886b2645b6649201495762adc5af96e.tar.gz pttbbs-0764d07f9886b2645b6649201495762adc5af96e.tar.bz2 pttbbs-0764d07f9886b2645b6649201495762adc5af96e.tar.lz pttbbs-0764d07f9886b2645b6649201495762adc5af96e.tar.xz pttbbs-0764d07f9886b2645b6649201495762adc5af96e.tar.zst pttbbs-0764d07f9886b2645b6649201495762adc5af96e.zip |
add a simple help page to calendar
take the format of 19XX instead of XX
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3353 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/calendar.c')
-rw-r--r-- | mbbsd/calendar.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c index f3777aab..ba0fb45a 100644 --- a/mbbsd/calendar.c +++ b/mbbsd/calendar.c @@ -38,28 +38,36 @@ Days(int y, int m, int d) return w; } -static int -ParseDate(char *date, event_t * t) +int ParseDate(const char *date, int *year, int *month, int *day) { char *y, *m, *d; + char buf[128]; - y = strtok(date, "/"); + strlcpy(buf, date, sizeof(buf)); + y = strtok(buf, "/"); m = strtok(NULL, "/"); d = strtok(NULL, ""); if (!y || !m || !d) return 1; - t->year = atoi(y); - t->month = atoi(m); - t->day = atoi(d); - if (t->year < 1 || t->month < 1 || t->month > 12 || - t->day < 1 || t->day > MonthDay(t->month, IsLeap(t->y))) + *year = atoi(y); + *month = atoi(m); + *day = atoi(d); + if (*year < 1 || *month < 1 || *month > 12 || + *day < 1 || *day > MonthDay(*month, IsLeap(*year))) return 1; - t->days = Days(t->year, t->month, t->day); return 0; } static int +ParseEventDate(const char *date, event_t * t) +{ + int retval = ParseDate(date, &t->year, &t->month, &t->day); + t->days = Days(t->year, t->month, t->day); + return retval; +} + +static int ParseColor(const char *color) { struct { @@ -147,7 +155,7 @@ ReadEvent(int today) continue; t = malloc(sizeof(event_t)); - if (ParseDate(date, t) || t->days < today) { + if (ParseEventDate(date, t) || t->days < today) { free(t); continue; } @@ -301,8 +309,8 @@ calendar(void) snow.tm_hour >= 12 ? 'p' : 'a'); } else if (i >= 2 && e) { prints("\t" ANSI_COLOR(1;37) - "(" ANSI_COLOR(%d) "%3d" - ANSI_COLOR(37) ")" + "(©|¦³ " ANSI_COLOR(%d) "%3d" + ANSI_COLOR(37) " ¤Ñ)" ANSI_RESET " %02d/%02d %s", e->color, e->days - today, e->month, e->day, e->content); |