use local date format
authorChristian Weiske <cweiske@cweiske.de>
Tue, 18 Feb 2014 20:21:26 +0000 (21:21 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 18 Feb 2014 20:21:26 +0000 (21:21 +0100)
src/bdrem/Renderer.php
src/bdrem/Renderer/Console.php
src/bdrem/Renderer/HtmlTable.php

index e6f633b..363d413 100644 (file)
@@ -18,5 +18,19 @@ abstract class Renderer
     }
 
     abstract public function render($arEvents);
+
+    protected function getLocalDate($dateStr)
+    {
+        if ($dateStr{0} != '?') {
+            return strftime('%x', strtotime($dateStr));
+        }
+
+        $dateStr = str_replace('????', '1899', $dateStr);
+        return str_replace(
+            array('1899', '99'),
+            array('????', '??'),
+            strftime('%x', strtotime($dateStr))
+        );
+    }
 }
 ?>
index e88d57a..87eeb9a 100644 (file)
@@ -60,7 +60,7 @@ class Renderer_Console extends Renderer
                         $event->age,
                         wordwrap($event->title, 30, "\n", true),
                         wordwrap($event->type, 20, "\n", true),
-                        $event->date,
+                        $this->getLocalDate($event->date),
                         strftime('%a', strtotime($event->localDate))
                     ),
                     $colorCode
index d8a723e..2c792f8 100644 (file)
@@ -38,14 +38,14 @@ HTM;
                 . '<td class="r">%s</td>'
                 . '<td>%s</td>'
                 . '<td>%s</td>'
-                . '<td class="r">%s</td>'
+                . '<td>%s</td>'
                 . '<td>%s</td>'
                 . "</tr>\n",
                 $event->days,
                 $event->age,
                 htmlspecialchars($event->title),
                 htmlspecialchars($event->type),
-                $event->date,
+                $this->getLocalDate($event->date),
                 strftime('%a', strtotime($event->localDate))
             );
         }