UNPKG

@zstings/utils

Version:

javascript、typescript 工具函数库 文档地址 [utils 文档](https://zstings.github.io/utils/)

25 lines (24 loc) 816 B
/** * 获取从当前时间到指定年月之前的所有年月 * @param targetDateStr 年月组成的字符串 '2025-01' or '2025-1' * @return 年月字符串的数组 * @throws Invalid Date 参数targetDateStr无法转为Date时触发 * @category 时间Date * @example * 获取当前到2025-01的年月数组,假设当前时间为2025-03 * ```ts * getMonthsUntilDate('2025-01') // ['2025-03', '2025-02', '2025-01'] * ``` * @example * 获取当前到2025-05的年月数组,假设当前时间为2025-03 * ```ts * getMonthsUntilDate('2025-05') // ['2025-03', '2025-04', '2025-05'] * ``` * @example * 无实际传参时 * ```ts * getMonthsUntilDate('') // ['2025-03'] * getMonthsUntilDate() // ['2025-03'] * ``` */ export default function getMonthsUntilDate(targetDateStr: string): string[];