ohif-viewer/extensions/default/src/utils/getCurrentDicomDateTime.ts
2025-04-07 10:05:22 -04:00

21 lines
778 B
TypeScript

export const getSeriesDateTime = (jsDate: Date = new Date()) => {
const dicomDateTime = getDicomDateTime(jsDate);
return {
SeriesDate: dicomDateTime.date,
SeriesTime: dicomDateTime.time,
};
};
export const getDicomDateTime = (jsDate: Date = new Date()) => {
const month = String(jsDate.getUTCMonth() + 1).padStart(2, '0');
const day = String(jsDate.getUTCDate()).padStart(2, '0');
const year = String(jsDate.getUTCFullYear()).padStart(4, '0');
const date = `${year}${month}${day}`;
const hours = String(jsDate.getUTCHours()).padStart(2, '0');
const minutes = String(jsDate.getUTCMinutes()).padStart(2, '0');
const seconds = String(jsDate.getUTCSeconds()).padStart(2, '0');
const time = `${hours}${minutes}${seconds}`;
return { date, time };
};