This commit is contained in:
oneao committed 2026-01-30 17:22:20 +08:00
1 parent c62c9d080b
commit 6a8c31e20c
29 files changed
+1454 -357

No files matched your search

+14
View File
@@ -28,6 +28,10 @@ export function getCurrentYearMonth(format = 'YYYY-MM'): string {
return dayjs().format(format)
}
export function getCurrentYear(): string {
return dayjs().format('YYYY')
}
/** 字符串 / 数字 / Date → Date(无效返回 null) */
export function toDate(input: string | number | Date | undefined | null): Date {
if (!input)
@@ -105,3 +109,13 @@ export function formatRelativeTime(date: string | Date | number): string {
return `${years}年前`
}
}
// 获取本月的第一天
export function getStartOfMonth() {
return dayjs().startOf('month').format('YYYY-MM-DD')
}
// 获取本月的最后一天
export function getEndOfMonth() {
return dayjs().endOf('month').format('YYYY-MM-DD')
}