MCPcopy Create free account
hub / github.com/acode/cli / formatDate

Function formatDate

cli/commands/user.js:19–36  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

17};
18
19let formatDate = function(str) {
20
21 let date = new Date(str);
22 let months = 'January February March April May June July August September October November December'.split(' ');
23 let ends = ['th', 'st', 'nd', 'rd', 'th'];
24
25 let y = chalk.bold(date.getFullYear());
26 let m = chalk.bold(months[date.getMonth()]);
27 let d = chalk.bold(date.getDate());
28 let e = chalk.bold(ends[d] || 'th');
29 let hh = chalk.bold(formatDigits(date.getHours(), 2));
30 let mm = chalk.bold(formatDigits(date.getMinutes(), 2));
31 let ss = chalk.bold(formatDigits(date.getSeconds(), 2));
32 let ms = chalk.bold(formatDigits(date.valueOf() % 1000, 3));
33
34 return `${m} ${d}${e}, ${y} at ${hh}:${mm}:${ss}.${ms}`;
35
36};
37
38class UserCommand extends Command {
39

Callers

nothing calls this directly

Calls 1

formatDigitsFunction · 0.85

Tested by

no test coverage detected