Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement displaying last modified date in index #737

Merged
merged 1 commit into from Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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));
};