import { system } from "@minecraft/server";

system.runInterval(() => {
    // code
}, 24000);

export { holiDates1, now, getDateRangeInfo, getFormattedDateTime };

function getFormattedDateTime() {
    const now = new Date();
    const formatted = `${now.getMonth() + 1}/${now.getDate()}/${now.getFullYear()}`;
    return formatted;
}

function getDateRangeInfo(currentDate, targetDate, range) {
    const current = new Date(currentDate);
    const target = new Date(targetDate);

    current.setFullYear(2000);
    target.setFullYear(2000);

    const timeDiff = current.getTime() - target.getTime();
    const absTimeDiff = Math.abs(timeDiff);

    const rangesInMs = {
        milliseconds: range.milliseconds || 0,
        seconds: (range.seconds || 0) * 1000,
        minutes: (range.minutes || 0) * 1000 * 60,
        hours: (range.hours || 0) * 1000 * 60 * 60,
        days: (range.days || 0) * 1000 * 60 * 60 * 24,
        weeks: (range.weeks || 0) * 1000 * 60 * 60 * 24 * 7,
        months: (range.months || 0) * 1000 * 60 * 60 * 24 * 30
    };

    const totalRangeMs = Object.values(rangesInMs).reduce((sum, val) => sum + val, 0);

    const timeUnits = {
        days: Math.floor(absTimeDiff / (1000 * 60 * 60 * 24)),
        hours: Math.floor((absTimeDiff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
        minutes: Math.floor((absTimeDiff % (1000 * 60 * 60)) / (1000 * 60)),
        seconds: Math.floor((absTimeDiff % (1000 * 60)) / 1000)
    };

    return {
        isInRange: absTimeDiff <= totalRangeMs,
        timeDifference: {
            milliseconds: absTimeDiff,
            ...timeUnits
        },
        direction: timeDiff < 0 ? 'before' : timeDiff > 0 ? 'after' : 'same',
        isPast: timeDiff > 0,
        isFuture: timeDiff < 0,
        isSame: timeDiff === 0
    };
}

const holiDates1 = {
    easter1: new Date(2000, 3, 22),
    festive1: new Date(2000, 11, 26),
    halloween1: new Date(2000, 10, 1),
    summer1: new Date(2000, 7, 5),
};

const now = new Date();

