commit 759c043f6cf1870a6c8d123fb8b1453d699b4331
parent a888439978971f9f193641664779bdb4ac363ac2
Author: Ryan Jeffrey <ryan@ryanmj.xyz>
Date: Thu, 20 Jan 2022 03:32:26 -0800
Whitespace padding in date
Diffstat:
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/server.js b/server.js
@@ -23,11 +23,15 @@ function getMonthByNumber(i) {
// Get the mtime in the same format that LS would.
function lsTime(timeMS) {
let fileDate = new Date(timeMS);
+ console.log(fileDate, timeMS);
+ let addString = "";
// If the file was updated this year then set the last column to the
// hour and minute. Else, the last column should be the year.
if((new Date()).getFullYear() != fileDate.getFullYear())
- return `${getMonthByNumber(fileDate.getMonth())} ${fileDate.getDate()} ${fileDate.getHours()}:${fileDate.getMinutes()}`;
- return `${getMonthByNumber(fileDate.getMonth())} ${fileDate.getDate()} ${fileDate.getFullYear()}`;
+ addString = `${fileDate.getHours()}:${fileDate.getMinutes()}`;
+ else
+ addString = ` ${fileDate.getFullYear()}`;
+ return `${getMonthByNumber(fileDate.getMonth())} ${fileDate.getDate()} ${addString}`;
}
function permissionToString(i) {
@@ -60,7 +64,7 @@ function ls(thePath) {
perms: `${prefixChar}${permsResult}`,
numLinks: stats.nlink,
fileSize: stats.size,
- mtime: lsTime(stats.mtimeMS),
+ mtime: lsTime(stats.mtimeMs),
basename: path.parse(path.basename(thePath)).name,
};
return result;