Clock UI
π useEthiopianClock()
useEthiopianClock
is a headless hook that provides real-time Ethiopian and Gregorian time, updating every second. Itβs ideal for creating live digital or analog clocks.
β Usage
import { useEthiopianClock } from 'kenat-ui'
const { now, ethiopianTime, gregorianTime } = useEthiopianClock()
β
state
object
now
: The raw JavaScriptDate
object, which updates every second. This is useful for powering analog clock hands.ethiopianTime
: Akenat.Time
instance representing the current Ethiopian time, which is derived from the current hour and minute.gregorianTime
: A plain object{ hour, minute, second }
for the current Gregorian time.
β Example
import { useEthiopianClock } from 'kenat-ui';
import { toGeez } from 'kenat'; // Assuming 'toGeez' is available from the core kenat library
function LiveClock() {
const { ethiopianTime, gregorianTime } = useEthiopianClock();
return (
<div className="font-mono text-5xl">
<span>{ethiopianTime.hour}</span>:
<span>{ethiopianTime.minute}</span>:
<span>{gregorianTime.second}</span>
<span className="text-lg ml-2">{ethiopianTime.period}</span>
</div>
);
}
Last updated on