@odata2ts/converter-luxon
Version:
Luxon based odata2ts compatible converters for date and time related OData types
24 lines • 773 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.dateToLuxonConverter = void 0;
const luxon_1 = require("luxon");
exports.dateToLuxonConverter = {
id: "dateToLuxonConverter",
from: "Edm.Date",
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) {
var _a;
if (!value) {
return value;
}
return value.isValid ? (_a = value.toISO()) === null || _a === void 0 ? void 0 : _a.split("T")[0] : undefined;
},
};
//# sourceMappingURL=DateToLuxonConverter.js.map