(time: number | string)
| 320 | }; |
| 321 | |
| 322 | export const transactionTimeToReadable = (time: number | string) => { |
| 323 | if (time === -1) { |
| 324 | return 'unknown'; |
| 325 | } |
| 326 | if (+time < 1000000000000) { |
| 327 | // converting timestamp to milliseconds timestamp |
| 328 | // (we dont expect timestamps before September 9, 2001 so this conversion is fine) |
| 329 | time = +time * 1000; |
| 330 | } |
| 331 | if (time === 0) { |
| 332 | return loc._.never; |
| 333 | } |
| 334 | let ret; |
| 335 | try { |
| 336 | ret = dayjs(time).fromNow(); |
| 337 | } catch (_) { |
| 338 | console.warn('incorrect locale set for dayjs'); |
| 339 | return String(time); |
| 340 | } |
| 341 | return ret; |
| 342 | }; |
| 343 | |
| 344 | const ONE_DAY_MS = 24 * 60 * 60 * 1000; |
| 345 |
no outgoing calls
no test coverage detected