All files / shared / utils format.ts

88.88% Statements 8/9
50% Branches 1/2
100% Functions 1/1
100% Lines 8/8

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  92x 92x 92x 92x 92x 92x 92x 92x    
export function formatDateTime(dateStr: string | null | undefined): string {
 I if (!dateStr) return '\u2014'
  const d = new Date(dateStr)
  const year = d.getFullYear()
  const month = String(d.getMonth() + 1).padStart(2, '0')
  const day = String(d.getDate()).padStart(2, '0')
  const hours = String(d.getHours()).padStart(2, '0')
  const minutes = String(d.getMinutes()).padStart(2, '0')
  return `${year}-${month}-${day} ${hours}:${minutes}`
}