david
3 years ago
5 changed files with 110 additions and 8 deletions
@ -1,18 +1,18 @@ |
|||||||
const React = require('react'); |
const React = require('react'); |
||||||
const dayjs = require('dayjs'); |
const dayjs = require('dayjs'); |
||||||
|
|
||||||
export const TimeBetweenRows = ({ row, nextRow }) => { |
export const TimeDiff = ({ row, nextRow }) => { |
||||||
if (nextRow) { |
if (nextRow) { |
||||||
|
const now = dayjs(); |
||||||
const firstDate = dayjs(row.timestamp); |
const firstDate = dayjs(row.timestamp); |
||||||
const secondDate = dayjs(nextRow.timestamp); |
const secondDate = dayjs(nextRow.timestamp); |
||||||
const theDiff = firstDate.diff(secondDate); |
const theDiff = |
||||||
|
row.id === nextRow.id ? now.diff(firstDate) : firstDate.diff(secondDate); |
||||||
const theSeconds = theDiff / 1000; |
const theSeconds = theDiff / 1000; |
||||||
const theMinutes = theSeconds / 60; |
const theMinutes = theSeconds / 60; |
||||||
const theHours = theMinutes / 60; |
const theHours = theMinutes / 60; |
||||||
const theDays = theHours / 24; |
const theDays = theHours / 24; |
||||||
|
|
||||||
// console.log(theDiff, theSeconds, theMinutes, theHours, theDays); |
|
||||||
|
|
||||||
const renderSecs = <>{theSeconds === 1 ? 'sec' : 'secs'}</>; |
const renderSecs = <>{theSeconds === 1 ? 'sec' : 'secs'}</>; |
||||||
const renderMins = <>{theMinutes === 1 ? 'min ' : 'mins '}</>; |
const renderMins = <>{theMinutes === 1 ? 'min ' : 'mins '}</>; |
||||||
const renderHrs = <>{theHours === 1 ? 'hr ' : 'hrs '}</>; |
const renderHrs = <>{theHours === 1 ? 'hr ' : 'hrs '}</>; |
Loading…
Reference in new issue