tell-me-when
Version:
human relative date and time parser
22 lines (20 loc) • 779 B
JavaScript
;
var _index = require("./index.js");
const expr = process.argv.slice(2).filter(a => !a.startsWith('--')).join(' ');
const iso = process.argv.includes('--iso');
let result;
try {
result = (0, _index.tellMeWhen)(expr);
} catch (error) {
if (error instanceof _index.ParseError) {
// eslint-disable-next-line no-console
console.error(expr);
// eslint-disable-next-line no-console
console.error(`${' '.repeat(error.from)}${'^'.repeat(Math.max(1, error.to - error.from))} parse error`);
}
process.exit(1);
}
const formatDate = iso ? d => d.toISOString() : d => d.toLocaleString();
// eslint-disable-next-line no-console
console.log(Array.isArray(result) ? result.map(formatDate).join(' to ') : formatDate(result));
//# sourceMappingURL=cli.js.map