mirror of
https://github.com/m1ngsama/FUJI.git
synced 2025-12-25 02:56:38 +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 date = new Date(dateString)
|
||||||
const year = date.getFullYear()
|
const year = date.getFullYear()
|
||||||
const month = date.getMonth() + 1
|
const month = date.getMonth() + 1
|
||||||
|
|
@ -6,20 +6,7 @@ export function formatDate(dateString) {
|
||||||
return year + " 年 " + month + " 月 " + day + " 日"
|
return year + " 年 " + month + " 月 " + day + " 日"
|
||||||
}
|
}
|
||||||
|
|
||||||
// debounce function
|
export function formatDateV2(date: string) {
|
||||||
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) {
|
|
||||||
// 创建一个Date对象
|
// 创建一个Date对象
|
||||||
const d = new Date(date)
|
const d = new Date(date)
|
||||||
// 使用toLocaleString方法返回本地时间字符串
|
// 使用toLocaleString方法返回本地时间字符串
|
||||||
Loading…
Reference in a new issue