Commit e0529745 by lijiabin

【需求 20331】 feat: 加入工具函数

parent 173706f0
import { ArticleTypeEnum } from '@/constants'
import { useUserStore } from '@/stores'
import { storeToRefs } from 'pinia'
import dayjs from 'dayjs'
/**
* 页面改变标题
* @param title
......@@ -124,3 +125,11 @@ export function formatDuration(seconds: number): string {
const secs = Math.floor(seconds % 60)
return `${mins}:${secs.toString().padStart(2, '0')}`
}
// 处理秒级时间戳 把当前秒级时间戳 转换成 当前 23:59:59 的秒级时间戳
export function formatSeconds(seconds: number): number
export function formatSeconds(seconds: string): string
export function formatSeconds(seconds: string | number) {
const res = dayjs.unix(Number(seconds)).endOf('day').unix()
return typeof seconds === 'number' ? res : res.toString()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment