summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2007-09-21 01:33:21 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2007-09-21 01:33:21 +0800
commit6aafb916266e197bdf3261981aad70e9f94b3153 (patch)
tree6f24aad28f2b4b71382b95a1d9f003ec81e7bdf0 /mbbsd
parentb9539de0ffa696b5f8debe2d3e91e4eab81004fa (diff)
downloadpttbbs-6aafb916266e197bdf3261981aad70e9f94b3153.tar
pttbbs-6aafb916266e197bdf3261981aad70e9f94b3153.tar.gz
pttbbs-6aafb916266e197bdf3261981aad70e9f94b3153.tar.bz2
pttbbs-6aafb916266e197bdf3261981aad70e9f94b3153.tar.lz
pttbbs-6aafb916266e197bdf3261981aad70e9f94b3153.tar.xz
pttbbs-6aafb916266e197bdf3261981aad70e9f94b3153.tar.zst
pttbbs-6aafb916266e197bdf3261981aad70e9f94b3153.zip
* fix bug: skip bad date format.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3565 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/calendar.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c
index 52a0c111..865e52be 100644
--- a/mbbsd/calendar.c
+++ b/mbbsd/calendar.c
@@ -15,6 +15,7 @@ MonthDay(int m, int leap)
{
int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+ assert(1<=m && m<=12);
return leap && m == 2 ? 29 : day[m - 1];
}
@@ -40,6 +41,9 @@ Days(int y, int m, int d)
return w;
}
+/**
+ * return 1 if date is invalid
+ */
int ParseDate(const char *date, int *year, int *month, int *day)
{
char *y, *m, *d;
@@ -62,10 +66,15 @@ int ParseDate(const char *date, int *year, int *month, int *day)
return 0;
}
+/**
+ * return 1 if date is invalid
+ */
static int
ParseEventDate(const char *date, event_t * t)
{
int retval = ParseDate(date, &t->year, &t->month, &t->day);
+ if (retval)
+ return retval;
t->days = Days(t->year, t->month, t->day);
return retval;
}