subtitle handling, prettified dates. bugfixes and better errors
[scpubgit/SCS.git] / lib / SCSite / Page.pm
index b1b7e6f..7d09627 100644 (file)
@@ -1,9 +1,20 @@
 package SCSite::Page;
 
 use IO::All;
+use Time::Local qw(timelocal);
 use Moo;
 
-has $_ => (is => 'ro') for qw(title description keywords body created path);
+has $_ => (is => 'ro') for qw(
+  title subtitle description keywords body created path
+);
+
+sub published_at {
+  $_[0]->created
+    ? scalar localtime timelocal
+        map +(@{$_}[0..3], $_->[4]-1, $_->[5]-1900),
+          [ reverse split '\D+', $_[0]->created ]
+    : ''
+}
 
 has "_$_" => (is => 'ro', init_arg => $_) for qw(page_set);