32 lines
626 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import moment from "moment"
/**
* 获取今天是今年的第几周like 2024-05
*/
export const getWeekTimeWithYear = () => {
return moment().format("YYYY-WW")
}
/**
* 获取上周是今年的第几周like 2024-04
*/
export const getPrevWeekWithYear = () => {
return moment().subtract(1, "weeks").format("YYYY-WW")
}
/**
* 秒转分钟,保留一位小数
*/
export const sec2min = (sec: number) => {
return (sec / 60).toFixed(1)
}
/**
* 秒转分钟,格式为 1m 30s
*/
export const sec2minStr = (sec: number) => {
const min = Math.floor(sec / 60)
const s = sec % 60
return `${min}m ${s}s`
}