mirror of
https://github.com/langgenius/dify.git
synced 2025-07-27 11:30:14 +00:00
15 lines
434 B
TypeScript
15 lines
434 B
TypeScript
import type { Dayjs } from 'dayjs'
|
|
import dayjs from 'dayjs'
|
|
|
|
export const timeOfDayToDayjs = (timeOfDay: number): Dayjs => {
|
|
const hours = Math.floor(timeOfDay / 3600)
|
|
const minutes = (timeOfDay - hours * 3600) / 60
|
|
const res = dayjs().startOf('day').hour(hours).minute(minutes)
|
|
return res
|
|
}
|
|
|
|
export const dayjsToTimeOfDay = (date?: Dayjs): number => {
|
|
if(!date) return 0
|
|
return date.hour() * 3600 + date.minute() * 60
|
|
}
|