Add daily/weekly level endpoint

This commit is contained in:
Lncvrt committed 2026-02-20 21:16:24 -07:00
1 parent 0a391543d2
commit 4292f8137a
5 files changed
+70 -3

No files matched your search

+23
View File
@@ -21,6 +21,7 @@ export const encodeGJP2 = async (password = '', salt = 'mI29fmAnxgTs') => {
.map(b => b.toString(16).padStart(2, '0'))
.join('')
}
export const generateTimeLength = (ms: number): string => {
const minutes = Math.floor(ms / 60000)
const seconds = Math.floor((ms % 60000) / 1000)
@@ -31,3 +32,25 @@ export const generateTimeLength = (ms: number): string => {
return `${minutes}:${secStr}.${msStr}`
}
export const formatTime = (seconds: number): string => {
const units = [
{ label: 'y', value: 365 * 24 * 3600 },
{ label: 'mo', value: 30 * 24 * 3600 },
{ label: 'd', value: 24 * 3600 },
{ label: 'h', value: 3600 },
{ label: 'm', value: 60 },
{ label: 's', value: 1 }
]
const parts = []
for (const { label, value } of units) {
const amount = Math.floor(seconds / value)
if (amount) {
parts.push(`${amount}${label}`)
seconds %= value
}
}
return parts.join(' ') || '0s'
}