mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 18:33:53 +00:00
19 lines
567 B
React
19 lines
567 B
React
import styles from './Countdown.module.css';
|
|
|
|
function display(seconds) {
|
|
const format = (val) => `0${Math.floor(val)}`.slice(-2);
|
|
const hours = seconds / 3600;
|
|
const minutes = (seconds % 3600) / 60;
|
|
|
|
if (hours < 1) return [minutes, seconds % 60].map(format).join(':');
|
|
else return [hours, minutes, seconds % 60].map(format).join(':');
|
|
}
|
|
|
|
export default function Countdown({ time, small }) {
|
|
return (
|
|
<div className={small ? styles.countdownClockSmall : styles.countdownClock}>
|
|
{time === null ? '- -:- -' : display(time * 60)}
|
|
</div>
|
|
);
|
|
}
|