This commit is contained in:
oneao committed 2025-11-17 17:30:20 +08:00
1 parent 18e9d94b77
commit 1f82f1dd1f
16 files changed
+1048 -297

No files matched your search

+6 -12
View File
@@ -2,31 +2,25 @@
import Big from 'big.js'
/**
* 加法
* @param a string number
* @param b string number
* @returns string number
* 加法(保留两位小数)
*/
export function add(a: string | number, b: string | number): string {
try {
return new Big(a).plus(new Big(b)).toString()
return new Big(a).plus(new Big(b)).toFixed(2) // ⭐ 保留两位
}
catch {
return '0'
return '0.00'
}
}
/**
* 减法
* @param a string number
* @param b string number
* @returns string number
* 减法(保留两位小数)
*/
export function sub(a: string | number, b: string | number): string {
try {
return new Big(a).minus(new Big(b)).toString()
return new Big(a).minus(new Big(b)).toFixed(2) // ⭐ 保留两位
}
catch {
return '0'
return '0.00'
}
}
@@ -62,3 +62,9 @@ export function toDateTimeString(date: string | number | Date): string {
const d = dayjs(toDate(date))
return d.isValid() ? d.format('YYYY-MM-DD HH:mm:ss') : ''
}
export function isInMonth(date: string, month: string): boolean {
// date 形如 "2025-01-12"
// month 形如 "2025-01"
return dayjs(date).format('YYYY-MM') === month
}