Skip to content

Commit b9bca4e

Browse files
authored
Merge pull request #737 from owenl131/autoindex-display-last-modified
Implement displaying last modified date in index
2 parents 08ffbf5 + a5c2768 commit b9bca4e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/core/show-dir/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const styles = require('./styles');
4+
const lastModifiedToString = require('./last-modified-to-string');
45
const permsToString = require('./perms-to-string');
56
const sizeToString = require('./size-to-string');
67
const sortFiles = require('./sort-files');
@@ -114,6 +115,7 @@ module.exports = (opts) => {
114115
html += `<td class="perms"><code>(${permsToString(file[1])})</code></td>`;
115116
}
116117
html +=
118+
`<td class="last-modified">${lastModifiedToString(file[1])}</td>` +
117119
`<td class="file-size"><code>${sizeToString(file[1], humanReadable, si)}</code></td>` +
118120
`<td class="display-name"><a href="${href}">${displayName}</a></td>` +
119121
'</tr>\n';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
module.exports = function lastModifiedToString(stat) {
4+
const t = new Date(stat.mtime);
5+
return (("0" + (t.getDate())).slice(-2) + '-' +
6+
t.toLocaleString('default', { month: 'short' }) + '-' +
7+
t.getFullYear() + ' ' +
8+
("0" + t.getHours()).slice(-2) + ':' +
9+
("0" + t.getMinutes()).slice(-2));
10+
};

0 commit comments

Comments
 (0)