nieuws/feed: conform article dates to RFC-3339
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 25 Jun 2019 18:24:22 +0000 (20:24 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 25 Jun 2019 18:24:22 +0000 (20:24 +0200)
Omit duplicate date match (from dateparts) and append time part as required
by specs and Atom syntax.

nieuws.inc.php

index 40432a9c22cfc6aa1411ac866e6cf9e5e577ac9a..34b565a1358b656df7072c20d8d1ef222a31e50f 100644 (file)
@@ -9,8 +9,8 @@ function showdate($parts)
 {
        global $monthname;
        return implode(' ', array_filter([
-               intval(@$parts[3]), $parts[2] > 0 ? $monthname[intval($parts[2])] : '', $parts[1],
-               count($parts) > 6 ? "$parts[4]:$parts[5]" : '',
+               intval(@$parts[2]), $parts[1] > 0 ? $monthname[intval($parts[1])] : '', $parts[0],
+               count($parts) > 5 ? "$parts[3]:$parts[4]" : '',
        ]));
 }
 
@@ -61,12 +61,13 @@ class ArchiveArticle
        function dateparts()
        {
                preg_match('< / (\d{4}) [/-] (\d{2}) (?:- (\d{2}) )? - >x', $this->page, $ymd);
+               array_shift($ymd);
                return $ymd;
        }
 
        function dateiso()
        {
-               return implode('-', $this->dateparts());
+               return implode('-', $this->dateparts()) . 'T12:00:00+02:00';
        }
 
        function date()
@@ -157,7 +158,7 @@ function printtoc($input, $class = FALSE)
                $html = $article->safetitle;
                $dateparts = $article->dateparts;
                if ($class) {
-                       $dateparts[1] = NULL;  # omit year
+                       $dateparts[0] = NULL;  # omit year
                }
                $html .= sprintf(' <small class="date">%s</small>', showdate($dateparts));
                if ($class == 'gallery' and $article->img) {