"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeUnixNano = decodeUnixNano;
exports.encodeUnixNano = encodeUnixNano;
exports.compareISOTimes = compareISOTimes;
exports.getEarlierTime = getEarlierTime;
exports.getLaterTime = getLaterTime;
exports.isValidISOTime = isValidISOTime;
exports.getTimeDifference = getTimeDifference;
function decodeUnixNano(timeUnixNano) {
    const milliseconds = Number(timeUnixNano) / 1000000;
    return new Date(milliseconds).toISOString();
}
function encodeUnixNano(isoTimeString) {
    const milliseconds = new Date(isoTimeString).getTime();
    const nanoseconds = milliseconds * 1000000;
    return nanoseconds.toString();
}
function compareISOTimes(time1, time2) {
    const date1 = new Date(time1);
    const date2 = new Date(time2);
    if (date1 < date2)
        return -1;
    if (date1 > date2)
        return 1;
    return 0;
}
function getEarlierTime(time1, time2) {
    return compareISOTimes(time1, time2) <= 0 ? time1 : time2;
}
function getLaterTime(time1, time2) {
    return compareISOTimes(time1, time2) >= 0 ? time1 : time2;
}
function isValidISOTime(timeString) {
    try {
        const date = new Date(timeString);
        return !isNaN(date.getTime()) && timeString === date.toISOString();
    }
    catch (_a) {
        return false;
    }
}
function getTimeDifference(start, end) {
    const startTime = new Date(start).getTime();
    const endTime = new Date(end).getTime();
    return endTime - startTime;
}
