@odata2ts/converter-luxon
Version:
Luxon based odata2ts compatible converters for date and time related OData types
23 lines • 766 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.timeOfDayToLuxonConverter = void 0;
const luxon_1 = require("luxon");
exports.timeOfDayToLuxonConverter = {
id: "timeOfDayToLuxonConverter",
from: "Edm.TimeOfDay",
to: "luxon.DateTime",
convertFrom: function (value) {
if (typeof value !== "string") {
return value;
}
const luxon = luxon_1.DateTime.fromISO(value);
return luxon.isValid ? luxon : undefined;
},
convertTo: function (value) {
if (!value) {
return value;
}
return value.isValid ? value.toFormat(`hh:mm:ss${value.millisecond ? ".S" : ""}`) : undefined;
},
};
//# sourceMappingURL=TimeOfDayToLuxonConverter.js.map