All files / extensions/default/src/utils getCurrentDicomDateTime.ts

15.38% Statements 2/13
0% Branches 0/2
0% Functions 0/2
15.38% Lines 2/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2134x               34x                        
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 };
};