gitlab_monitor/utils/timeTools.ts
zhaoyingbo da1c5f7580
All checks were successful
CI Monitor CI/CD / build-image (push) Successful in 32s
CI Monitor CI/CD / deploy (push) Successful in 40s
feat: 支持对PipeLine WebHooks的处理 #1
2024-07-26 07:17:32 +00:00

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`
}