mirror of
https://github.com/m1ngsama/FUJI.git
synced 2025-12-24 10:51:27 +00:00
refactor utils to ts
This commit is contained in:
parent
25d31db78e
commit
9577954c27
1 changed files with 2 additions and 15 deletions
|
|
@ -1,4 +1,4 @@
|
|||
export function formatDate(dateString) {
|
||||
export function formatDate(dateString: string) {
|
||||
const date = new Date(dateString)
|
||||
const year = date.getFullYear()
|
||||
const month = date.getMonth() + 1
|
||||
|
|
@ -6,20 +6,7 @@ export function formatDate(dateString) {
|
|||
return year + " 年 " + month + " 月 " + day + " 日"
|
||||
}
|
||||
|
||||
// debounce function
|
||||
export function debounce(fn, delay) {
|
||||
let timer = null
|
||||
return function () {
|
||||
const context = this
|
||||
const args = arguments
|
||||
clearTimeout(timer)
|
||||
timer = setTimeout(function () {
|
||||
fn.apply(context, args)
|
||||
}, delay)
|
||||
}
|
||||
}
|
||||
|
||||
export function formatDateV2(date) {
|
||||
export function formatDateV2(date: string) {
|
||||
// 创建一个Date对象
|
||||
const d = new Date(date)
|
||||
// 使用toLocaleString方法返回本地时间字符串
|
||||
Loading…
Reference in a new issue