FCC-Project_Timestamp-Gener.../scripts/timeprocessor.js
2025-03-19 14:26:04 +00:00

18 lines
No EOL
456 B
JavaScript

/* Process the conversion of times. */
class TimeProcessor {
static convert(DATE) {
try {
DATE = (DATE != null && isNaN(Number(DATE))) ? DATE : Number(DATE);
let TIME = new Date(DATE);
if (TIME == "Invalid Date") {throw EvalError};
return ({"unix": TIME.getTime(), "utc": TIME.toUTCString()});
} catch(err) {
throw(err);
}
}
}
module.exports = {TimeProcessor};