mirror of
https://github.com/sheptikhinv/timers.git
synced 2026-02-07 07:41:36 +05:00
refactor some functions
This commit is contained in:
parent
981ef867fb
commit
8f69ed3b58
3 changed files with 19 additions and 15 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
import {useEffect, useState} from 'react';
|
||||
import Timer from '../../components/Timer/Timer';
|
||||
import styles from './Timers.module.css';
|
||||
import {formatFullTime} from "../../helpers/Formatters.ts";
|
||||
|
||||
const Timers = () => {
|
||||
const [time, setTime] = useState(new Date());
|
||||
|
|
@ -13,18 +14,12 @@ const Timers = () => {
|
|||
return () => clearInterval(intervalId);
|
||||
}, [])
|
||||
|
||||
const formatTime = (date: Date) => {
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0');
|
||||
return `${hours}:${minutes}:${seconds}`;
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.content}>
|
||||
<header className={styles.header}>
|
||||
<a className={`${styles.header_text} ${styles.title}`}>MetaTimer</a>
|
||||
<a className={`${styles.header_text} ${styles.title}`}>{formatTime(time)}</a>
|
||||
<a className={`${styles.header_text} ${styles.title}`}>{formatFullTime(time)}</a>
|
||||
</header>
|
||||
<div className={styles.timers_container}>
|
||||
<Timer/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue