Skip to content

Commit

Permalink
Format the datafield in the filebrowser using moment.js
Browse files Browse the repository at this point in the history
Eventually we probably want to print these fields in the right timezone
depending on the setting the end-user has for a given session.
  • Loading branch information
Marco van Wieringen committed Jun 4, 2016
1 parent 0cd2f44 commit 55be16b
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions module/Restore/view/restore/restore/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,13 @@ $this->headTitle($title);
<?php
echo $this->headScript()->prependFile($this->basePath() . '/js/jstreegrid.js');
echo $this->headScript()->prependFile($this->basePath() . '/js/jstree.min.js');
echo $this->headScript()->prependFile($this->basePath() . '/js/moment.min.js');
echo $this->headScript()->prependFile($this->basePath() . '/js/moment-with-locales.min.js');
echo $this->headLink()->prependStylesheet($this->basePath() . '/css/jstree.min.css');
?>

<script type="text/javascript">

function unix_to_human(UNIX_timestamp) {

var t = new Date(UNIX_timestamp * 1000);
var formatted = t.toUTCString();

return formatted;

}

function format_bytes(v) {
if(v == 0) {
return "0.00 B";
Expand Down Expand Up @@ -247,7 +240,7 @@ $this->headTitle($title);
columns: [
{ width: 500, header: '<?php echo $this->translate("Name"); ?>', title: "_DATA_" },
{ width: 125, header: '<?php echo $this->translate("Size"); ?>', value: function(node) { return(format_bytes(node.data.stat.size)); } },
{ header: '<?php echo $this->translate("Date"); ?>', value: function(node) { return(unix_to_human(node.data.stat.mtime)); } }
{ header: '<?php echo $this->translate("Date"); ?>', value: function(node) { return(moment.unix(node.data.stat.mtime).format("YYYY-MM-DD HH:mm:ss")); } }
],
resizable: true,
},
Expand Down

0 comments on commit 55be16b

Please sign in to comment.