20 lines
415 B
TypeScript
20 lines
415 B
TypeScript
import dayjs from 'dayjs';
|
|
|
|
export function combineDateTime(date: Date, time: string) {
|
|
const [hours = '00', minutes = '00'] = time.split(':');
|
|
|
|
return new Date(
|
|
date.getFullYear(),
|
|
date.getMonth(),
|
|
date.getDate(),
|
|
Number.parseInt(hours, 10),
|
|
Number.parseInt(minutes, 10),
|
|
);
|
|
}
|
|
|
|
export function getTimeString(date: Date) {
|
|
if (!date) return '-';
|
|
|
|
return dayjs(date).format('HH:mm');
|
|
}
|