Display dates in human format
authorVincent Tondellier <tonton+hg@team1664.org>
Sun, 14 Feb 2016 23:56:24 +0100
changeset 104 b75005d8b002
parent 103 95f4e3c47dd4
child 105 d7258a3a926c
Display dates in human format
lib/CrashTest/Helper/DateTime.pm
templates/report/client_info.html.ep
templates/report/crash.html.ep
templates/reports/index.atom.ep
--- a/lib/CrashTest/Helper/DateTime.pm	Sun Feb 14 23:47:24 2016 +0100
+++ b/lib/CrashTest/Helper/DateTime.pm	Sun Feb 14 23:56:24 2016 +0100
@@ -30,6 +30,18 @@
         return "" unless $d;
         $d->strftime("%FT%TZ");
     });
+
+    $app->helper(human_date_from_epoch => sub {
+        my ($c, $ts) = @_;
+        my $d;
+        eval {
+            $d = DateTime->from_epoch(epoch => $ts);
+        };
+        $c->app->log->warn($@) if $@;
+        return "" unless $d;
+        $d->set_time_zone('local')->strftime("%F %T");
+    });
+
 }
 
 sub _date_from_db_utc {
--- a/templates/report/client_info.html.ep	Sun Feb 14 23:47:24 2016 +0100
+++ b/templates/report/client_info.html.ep	Sun Feb 14 23:56:24 2016 +0100
@@ -1,10 +1,10 @@
 <tr>
   %= t td => 'Start Time'
-  %= t td => $client_info->{StartupTime}
+  %= t td => human_date_from_epoch($client_info->{StartupTime})
 </tr>
 <tr>
   %= t td => 'Crash Time'
-  %= t td => $client_info->{CrashTime}
+  %= t td => human_date_from_epoch($client_info->{CrashTime})
 </tr>
 <tr>
   %= t td => 'Product'
--- a/templates/report/crash.html.ep	Sun Feb 14 23:47:24 2016 +0100
+++ b/templates/report/crash.html.ep	Sun Feb 14 23:56:24 2016 +0100
@@ -6,6 +6,8 @@
     %= t h3 => (class => 'panel-title') => "Crash for $processed_data->{client_info}->{ProductName} $processed_data->{client_info}->{Version}"
   % end
   %= t div => (class => 'panel-body') => begin
+    %= "Crash Time: " . human_date_from_epoch($processed_data->{client_info}->{CrashTime});
+    <br/>
     %= link_to "In crash group \"" . $crash_group->{title} . "\"" => url_for('group', uuid => $crash_group->{uuid})
    % end
 % end
--- a/templates/reports/index.atom.ep	Sun Feb 14 23:47:24 2016 +0100
+++ b/templates/reports/index.atom.ep	Sun Feb 14 23:56:24 2016 +0100
@@ -10,7 +10,7 @@
   <entry>
     <id>tag:crash,2014:uuid::<%= $crash->{uuid} =%></id>
     <link type="text/html" rel="alternate" href="<%= url_for('report', uuid => $crash->{uuid})->to_abs =%>"/>
-    <title><%= $crash->{p_name} =%>&nbsp;<%= $crash->{p_version} =%>: <%= $crash->{uuid} =%></title>
+    <title><%= $crash->{p_name} =%> <%= $crash->{p_version} =%>: <%= $crash->{uuid} =%></title>
     <updated><%= date_with_tz_from_db_utc($crash->{crash_time}) =%></updated>
     <published><%= date_with_tz_from_db_utc($crash->{crash_time}) =%></published>
     <author>