date_time(tm, 17);
}
+static void date_pm(struct tm *tm, int *num)
+{
+ int hour = *num;
+ *num = 0;
+
+ if (hour > 0 && hour < 12) {
+ tm->tm_hour = hour;
+ tm->tm_min = 0;
+ tm->tm_sec = 0;
+ }
+ if (tm->tm_hour > 0 && tm->tm_hour < 12)
+ tm->tm_hour += 12;
+}
+
+static void date_am(struct tm *tm, int *num)
+{
+ int hour = *num;
+ *num = 0;
+
+ if (hour > 0 && hour < 12) {
+ tm->tm_hour = hour;
+ tm->tm_min = 0;
+ tm->tm_sec = 0;
+ }
+}
+
static const struct special {
const char *name;
void (*fn)(struct tm *, int *);
{ "noon", date_noon },
{ "midnight", date_midnight },
{ "tea", date_tea },
+ { "PM", date_pm },
+ { "AM", date_am },
{ NULL }
};
char *end;
unsigned long number = strtoul(date, &end, 10);
+ switch (*end) {
+ case ':':
+ case '.':
+ case '/':
+ case '-':
+ if (isdigit(end[1])) {
+ int match = match_multi_number(number, *end, date, end, tm);
+ if (match)
+ return date + match;
+ }
+ }
+
*num = number;
return end;
}