miniprogram/node_modules/@vant/weapp/dist/calendar/utils.js

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

export const ROW_HEIGHT = 64;
export function formatMonthTitle(date) {
    if (!(date instanceof Date)) {
        date = new Date(date);
    }
    return `${date.getFullYear()}年${date.getMonth() + 1}月`;
}
export function compareMonth(date1, date2) {
    if (!(date1 instanceof Date)) {
        date1 = new Date(date1);
    }
    if (!(date2 instanceof Date)) {
        date2 = new Date(date2);
    }
    const year1 = date1.getFullYear();
    const year2 = date2.getFullYear();
    const month1 = date1.getMonth();
    const month2 = date2.getMonth();
    if (year1 === year2) {
        return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
    }
    return year1 > year2 ? 1 : -1;
}
export function compareDay(day1, day2) {
    if (!(day1 instanceof Date)) {
        day1 = new Date(day1);
    }
    if (!(day2 instanceof Date)) {
        day2 = new Date(day2);
    }
    const compareMonthResult = compareMonth(day1, day2);
    if (compareMonthResult === 0) {
        const date1 = day1.getDate();
        const date2 = day2.getDate();
        return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
    }
    return compareMonthResult;
}
export function getDayByOffset(date, offset) {
    date = new Date(date);
    date.setDate(date.getDate() + offset);
    return date;
}
export function getPrevDay(date) {
    return getDayByOffset(date, -1);
}
export function getNextDay(date) {
    return getDayByOffset(date, 1);
}
export function getToday() {
    const today = new Date();
    today.setHours(0, 0, 0, 0);
    return today;
}
export function calcDateNum(date) {
    const day1 = new Date(date[0]).getTime();
    const day2 = new Date(date[1]).getTime();
    return (day2 - day1) / (1000 * 60 * 60 * 24) + 1;
}
export function copyDates(dates) {
后面还有 23 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。