Skip to content

Commit

Permalink
Implement displaying last modified date in index
Browse files Browse the repository at this point in the history
  • Loading branch information
owenl131 committed Oct 2, 2021
1 parent 02d6500 commit a5c2768
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/core/show-dir/index.js
@@ -1,6 +1,7 @@
'use strict';

const styles = require('./styles');
const lastModifiedToString = require('./last-modified-to-string');
const permsToString = require('./perms-to-string');
const sizeToString = require('./size-to-string');
const sortFiles = require('./sort-files');
Expand Down Expand Up @@ -114,6 +115,7 @@ module.exports = (opts) => {
html += `<td class="perms"><code>(${permsToString(file[1])})</code></td>`;
}
html +=
`<td class="last-modified">${lastModifiedToString(file[1])}</td>` +
`<td class="file-size"><code>${sizeToString(file[1], humanReadable, si)}</code></td>` +
`<td class="display-name"><a href="${href}">${displayName}</a></td>` +
'</tr>\n';
Expand Down
10 changes: 10 additions & 0 deletions lib/core/show-dir/last-modified-to-string.js
@@ -0,0 +1,10 @@
'use strict';

module.exports = function lastModifiedToString(stat) {
const t = new Date(stat.mtime);
return (("0" + (t.getDate())).slice(-2) + '-' +
t.toLocaleString('default', { month: 'short' }) + '-' +
t.getFullYear() + ' ' +
("0" + t.getHours()).slice(-2) + ':' +
("0" + t.getMinutes()).slice(-2));
};

0 comments on commit a5c2768

Please sign in to comment.