- if (NULL == (n = n->next))
- m->meta.date = time(NULL);
- else if (0 == (m->meta.date = man_atotime(n->string))) {
- if ( ! man_vwarn(m, n->line, n->pos, "invalid date"))
- return(0);
+ /*
+ * Try to parse the date. If this works, stash the epoch (this
+ * is optimal because we can reformat it in the canonical form).
+ * If it doesn't parse, isn't specified at all, or is an empty
+ * string, then use the current date.
+ */
+
+ n = n->next;
+ if (n && n->string && *n->string) {
+ m->meta.date = mandoc_a2time
+ (MTIME_ISO_8601, n->string);
+ if (0 == m->meta.date) {
+ if ( ! man_nmsg(m, n, MANDOCERR_BADDATE))
+ return(0);
+ m->meta.rawdate = mandoc_strdup(n->string);
+ }
+ } else