Skip to content

Commit

Permalink
Merge pull request #158 from moov-io/file-show-localtime
Browse files Browse the repository at this point in the history
webui: offer the file creation time localized in the browser
  • Loading branch information
adamdecaf authored Aug 31, 2023
2 parents 67bb74f + 87d1c11 commit 7b356d1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion webui/file.html.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<pre>{{ .Contents }}</pre>
<hr />
<span class="metadata-header">File Metadata</span>
<table>
<table id="metadata-table">
{{ range $key, $value := .Metadata }}
<tr>
<td class="metadata-key">{{ $key }}</td>
Expand All @@ -39,5 +39,21 @@
<li><a href="{{ .HelpfulLinks.Returns }}">Return Codes</a></li>
</ul>
</main>
<script type="text/javascript">
(function() {
var table = document.querySelector("#metadata-table");
for (var i = 0, row; row = table.rows[i]; i++) {
for (var j = 0, col; col = row.cells[j]; j++) {
// If we can parse the value as a Date format it to the user's locale
var ts = new Date(row.cells[j].innerText);
if (!isNaN(ts)) {
var before = row.cells[j].innerText;
row.cells[j].innerHTML = "<span title='" + ts.toLocaleString() + "' style='text-decoration:underline;'>" + before + "</span>";
}
}
}
})();
</script>
</body>
</html>

0 comments on commit 7b356d1

Please sign in to comment.