@kermank/nldp
Version:
A modular date/time parser for converting natural language into dates and times
31 lines • 780 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertToTimeZone = convertToTimeZone;
exports.convertFromTimeZone = convertFromTimeZone;
/**
* Convert a UTC date to a date in the target timezone
*/
function convertToTimeZone(date, timeZone) {
if (!timeZone) {
return date;
}
const converted = date.setZone(timeZone);
if (!converted.isValid) {
return date;
}
return converted;
}
/**
* Convert a date from a source timezone to UTC
*/
function convertFromTimeZone(date, timeZone) {
if (!timeZone) {
return date;
}
const converted = date.setZone(timeZone).toUTC();
if (!converted.isValid) {
return date;
}
return converted;
}
//# sourceMappingURL=timezone.js.map