export function parseSitecoreDate(rawValue) {
    const value = rawValue?.trim();
    if (!value)
        return undefined;
    if (/^\d{8}T\d{6}Z$/.test(value)) {
        const date = new Date(value.replace(/(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z/, "$1-$2-$3T$4:$5:$6Z"));
        return isNaN(date.getTime()) ? undefined : date;
    }
    const date = new Date(value);
    return isNaN(date.getTime()) ? undefined : date;
}
function padDatePart(value) {
    return value.toString().padStart(2, "0");
}
export function toSitecoreDate(date) {
    return [
        date.getUTCFullYear(),
        padDatePart(date.getUTCMonth() + 1),
        padDatePart(date.getUTCDate()),
        "T",
        padDatePart(date.getUTCHours()),
        padDatePart(date.getUTCMinutes()),
        padDatePart(date.getUTCSeconds()),
        "Z",
    ].join("");
}
//# sourceMappingURL=sitecoreDate.js.map