(interval: IPostgresInterval)
| 169 | } |
| 170 | |
| 171 | export function formatInterval(interval: IPostgresInterval) { |
| 172 | const parts: string[] = []; |
| 173 | |
| 174 | if (interval.years) { |
| 175 | parts.push(`${interval.years}y`); |
| 176 | } |
| 177 | if (interval.months) { |
| 178 | parts.push(`${interval.months}m`); |
| 179 | } |
| 180 | if (interval.days) { |
| 181 | parts.push(`${interval.days}d`); |
| 182 | } |
| 183 | if (interval.hours) { |
| 184 | parts.push(`${interval.hours}h`); |
| 185 | } |
| 186 | if (interval.minutes) { |
| 187 | parts.push(`${interval.minutes}m`); |
| 188 | } |
| 189 | if (interval.seconds || interval.milliseconds) { |
| 190 | parts.push( |
| 191 | `${interval.seconds || 0}.${(interval.milliseconds || 0).toString().padStart(3, "0")}s`, |
| 192 | ); |
| 193 | } |
| 194 | |
| 195 | if (parts.length === 0) { |
| 196 | return "0s"; |
| 197 | } |
| 198 | |
| 199 | return parts.join(" "); |
| 200 | } |
| 201 | |
| 202 | export function formatDurationForAxis(durationMs: number): string { |
| 203 | // Cap at 24 hours (86,400,000 ms) |
no test coverage detected