Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 30x 30x 26x 9x 17x 17x 2x 15x 4x | import React from "react";
import "./Indicator.css";
import { timeDiff } from "./util";
import { isValidTimestamp } from "../timeUtils";
interface Props {
estimated: number;
now: number;
}
export default class TimeToArrivalIndicator extends React.PureComponent<Props> {
public render() {
const { estimated, now } = this.props;
if (isValidTimestamp(estimated) && isValidTimestamp(now)) {
if (estimated <= now) {
return "Due";
}
const { seconds, minutes } = timeDiff(estimated, now);
if (minutes === 0) {
return `${seconds}s`;
}
return `${minutes}m ${seconds}s`;
}
return "-";
}
}
|