refactor: enforce 800 line source limits

This commit is contained in:
caoxiaozhu
2026-06-22 11:58:53 +08:00
parent 08a4fa3577
commit 6d33ba5742
150 changed files with 27413 additions and 23791 deletions

View File

@@ -0,0 +1,33 @@
export function normalizeText(value) {
return String(value ?? '').trim()
}
export function compactText(value) {
return normalizeText(value).replace(/\s+/g, '')
}
export function normalizeDateText(value) {
const text = normalizeText(value)
const matched = text.match(/^(\d{4})[-/.年](\d{1,2})[-/.月](\d{1,2})/)
if (!matched) {
return ''
}
return [
matched[1],
String(matched[2]).padStart(2, '0'),
String(matched[3]).padStart(2, '0')
].join('-')
}
export function parseDate(value) {
const text = normalizeDateText(value)
if (!text) {
return null
}
const date = new Date(`${text}T00:00:00Z`)
return Number.isNaN(date.getTime()) ? null : date
}
export function formatDate(date) {
return date.toISOString().slice(0, 10)
}