24 lines
784 B
JavaScript
24 lines
784 B
JavaScript
global.ServerError = class extends Error {
|
|
constructor(status, msg) {
|
|
super(msg);
|
|
this.status = status;
|
|
}
|
|
}
|
|
|
|
global.currentTime = function () {
|
|
const now = new Date();
|
|
|
|
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
const day = String(now.getDate()).padStart(2, "0");
|
|
const year = now.getFullYear();
|
|
|
|
let hours = now.getHours();
|
|
const ampm = hours >= 12 ? "pm" : "am";
|
|
hours = hours % 12 || 12; // convert to 12-hour format
|
|
|
|
const minutes = String(now.getMinutes()).padStart(2, "0");
|
|
const seconds = String(now.getSeconds()).padStart(2, "0");
|
|
const ms = String(now.getMilliseconds()).padStart(4, "0"); // 4-digit like "5838"
|
|
|
|
return `${month}.${day}.${year}-${hours}:${minutes}:${seconds}${ms}${ampm}`;
|
|
} |