+ /* No date specified. */
+
+ if (nch == NULL) {
+ if (nbl == NULL)
+ mandoc_msg(MANDOCERR_DATE_MISSING, 0, 0, NULL);
+ else
+ mandoc_msg(MANDOCERR_DATE_MISSING, nbl->line,
+ nbl->pos, "%s", roff_name[nbl->tok]);
+ return mandoc_strdup("");
+ }
+ if (*nch->string == '\0') {
+ mandoc_msg(MANDOCERR_DATE_MISSING, nch->line,
+ nch->pos, "%s", roff_name[nbl->tok]);
+ return mandoc_strdup("");
+ }
+ if (strcmp(nch->string, "$" "Mdocdate$") == 0)
+ return time2a(time(NULL));
+
+ /* Valid mdoc(7) date format. */
+
+ if (a2time(&t, "$" "Mdocdate: %b %d %Y $", nch->string) ||
+ a2time(&t, "%b %d, %Y", nch->string)) {
+ cp = time2a(t);
+ if (t > time(NULL) + 86400)
+ mandoc_msg(MANDOCERR_DATE_FUTURE, nch->line,
+ nch->pos, "%s %s", roff_name[nbl->tok], cp);
+ else if (*nch->string != '$' &&
+ strcmp(nch->string, cp) != 0)
+ mandoc_msg(MANDOCERR_DATE_NORM, nch->line,
+ nch->pos, "%s %s", roff_name[nbl->tok], cp);
+ return cp;