()
| 116 | } |
| 117 | |
| 118 | createColumnDefs() { |
| 119 | const columnDefs = [] |
| 120 | this.dateColumns.forEach((newName, index) => { |
| 121 | columnDefs.push({ |
| 122 | targets: index, |
| 123 | render: (data, type) => { |
| 124 | if (type === "display") { |
| 125 | // Parse the date and return relative time |
| 126 | const timestamp = /^\d+$/.test(data) ? (String(data).length < 9 ? parseInt(data) * 1000 : parseInt(data)) : data |
| 127 | const date = dayjs(timestamp) |
| 128 | if (date.isValid()) { |
| 129 | return `<span title="${date.toLocaleString()}">${date.fromNow()}</span>` |
| 130 | } |
| 131 | } |
| 132 | // Return original data for sorting/filtering |
| 133 | return data |
| 134 | } |
| 135 | }) |
| 136 | }) |
| 137 | return columnDefs |
| 138 | } |
| 139 | |
| 140 | bindToHashChange() { |
| 141 | window.addEventListener("hashchange", () => { |
no test coverage detected