Files
NapCatQQ/.pnpm-store/v3/files/15/9c2a2fac6a342e3170618930fb9336423d7776391f410d31b9038d0657a37422706bbbeecc46dcd75c9a6ce2bcfc33194c2d83f76e326dca6032b45b8c35f6
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

20 lines
868 B
Plaintext

import { DateInput } from './types';
/**
* Calculates the difference in months between two dates.
* 计算两个日期之间的月份差
*
* @param date - The first date to compare.
* @param input - The second date to compare.
* @param asFloat - Whether to return the result as a float.
* @returns The difference in months between the two dates.
* @example
* ```ts
* diffInMonths(new Date(), new Date()); // 0
* diffInMonths(new Date(), new Date(Date.now() + 1000 * 60 * 60 * 24 * 30)); // 1
* diffInMonths(new Date(), new Date(Date.now() - 1000 * 60 * 60 * 24 * 30)); // -1
* diffInMonths(new Date(), new Date(Date.now() - 1000 * 60 * 60 * 24 * 30 * 2)); // -2
* diffInMonths(new Date(), new Date(Date.now() + 1000 * 60 * 60 * 24 * 30 * 2)); // 2
* ```
*/
export default function diffInMonths(date: Date, input: DateInput, asFloat?: boolean): number;