(interval: IPostgresInterval)
| 137 | } |
| 138 | |
| 139 | export function formatIntervalShort(interval: IPostgresInterval) { |
| 140 | if (interval.years) { |
| 141 | const years = roundIntervalValue(interval.years, interval.months, 6); |
| 142 | return `${years} ${pluralize(years, "year", "years")}`; |
| 143 | } |
| 144 | if (interval.months) { |
| 145 | const months = roundIntervalValue(interval.months, interval.days, 15); |
| 146 | return `${months} ${pluralize(months, "month", "months")}`; |
| 147 | } |
| 148 | if (interval.days) { |
| 149 | const days = roundIntervalValue(interval.days, interval.hours, 12); |
| 150 | return `${days} ${pluralize(days, "day", "days")}`; |
| 151 | } |
| 152 | if (interval.hours) { |
| 153 | const hours = roundIntervalValue(interval.hours, interval.minutes, 30); |
| 154 | return `${hours} ${pluralize(hours, "hour", "hours")}`; |
| 155 | } |
| 156 | if (interval.minutes) { |
| 157 | const minutes = roundIntervalValue(interval.minutes, interval.seconds, 30); |
| 158 | return `${minutes} ${pluralize(minutes, "minute", "minutes")}`; |
| 159 | } |
| 160 | if (interval.seconds) { |
| 161 | const seconds = roundIntervalValue( |
| 162 | interval.seconds, |
| 163 | interval.milliseconds, |
| 164 | 500, |
| 165 | ); |
| 166 | return `${seconds} ${pluralize(seconds, "second", "seconds")}`; |
| 167 | } |
| 168 | return "< 1 second"; |
| 169 | } |
| 170 | |
| 171 | export function formatInterval(interval: IPostgresInterval) { |
| 172 | const parts: string[] = []; |
no test coverage detected