( timestamp: number, ticks: number[], )
| 275 | }; |
| 276 | |
| 277 | export const getTimeTickLabel = ( |
| 278 | timestamp: number, |
| 279 | ticks: number[], |
| 280 | ): string => { |
| 281 | const date = dateNew(timestamp); |
| 282 | const year = dateGetUTCFullYear(date) + EMPTY_STRING; |
| 283 | const month = getPadded(dateGetUTCMonth(date) + 1); |
| 284 | const day = getPadded(dateGetUTCDate(date)); |
| 285 | const hour = getPadded(dateGetUTCHours(date)); |
| 286 | const minute = getPadded(dateGetUTCMinutes(date)); |
| 287 | const second = getPadded(dateGetUTCSeconds(date)); |
| 288 | const dateLabel = `${year}-${month}-${day}`; |
| 289 | let minDiff = infinity; |
| 290 | arrayForEach(ticks, (tick, index) => { |
| 291 | if (index > 0) { |
| 292 | minDiff = mathMin(minDiff, tick - ticks[index - 1]); |
| 293 | } |
| 294 | }); |
| 295 | minDiff = |
| 296 | minDiff == infinity |
| 297 | ? dateGetUTCHours(date) == 0 && |
| 298 | dateGetUTCMinutes(date) == 0 && |
| 299 | dateGetUTCSeconds(date) == 0 |
| 300 | ? DAY |
| 301 | : dateGetUTCSeconds(date) == 0 |
| 302 | ? HOUR |
| 303 | : SECOND |
| 304 | : minDiff; |
| 305 | |
| 306 | return minDiff < MINUTE |
| 307 | ? `${dateLabel} ${hour}:${minute}:${second}` |
| 308 | : minDiff < DAY |
| 309 | ? `${dateLabel} ${hour}:${minute}` |
| 310 | : minDiff < MONTH |
| 311 | ? dateLabel |
| 312 | : minDiff < YEAR |
| 313 | ? `${year}-${month}` |
| 314 | : year; |
| 315 | }; |
| 316 | |
| 317 | const floorTime = (timestamp: number, [unit, step]: TimeInterval): number => { |
| 318 | const date = dateNew(timestamp); |
no test coverage detected
searching dependent graphs…