meta: Make syntactically invalid dates an error

If for some reason you want to create <meta name="date" content="12345">,
this now requires [[!meta name="date" content="12345"]].

Signed-off-by: Simon McVittie <smcv@debian.org>
master
Simon McVittie 2018-03-21 09:00:41 +00:00
parent 3a640455cc
commit 88c66d3758
1 changed files with 12 additions and 2 deletions

View File

@ -155,14 +155,24 @@ sub preprocess (@) {
eval q{use Date::Parse}; eval q{use Date::Parse};
if (! $@) { if (! $@) {
my $time = str2time($value); my $time = str2time($value);
$IkiWiki::pagectime{$page}=$time if defined $time; if (defined $time) {
$IkiWiki::pagectime{$page}=$time;
}
else {
error(sprintf(gettext('cannot parse date/time: %s'), $value));
}
} }
} }
elsif ($key eq 'updated') { elsif ($key eq 'updated') {
eval q{use Date::Parse}; eval q{use Date::Parse};
if (! $@) { if (! $@) {
my $time = str2time($value); my $time = str2time($value);
$pagestate{$page}{meta}{updated}=$time if defined $time; if (defined $time) {
$pagestate{$page}{meta}{updated}=$time;
}
else {
error(sprintf(gettext('cannot parse date/time: %s'), $value));
}
} }
} }