mirror of
https://github.com/movie-web/movie-web.git
synced 2025-01-01 13:46:01 +00:00
Fix morning time
This commit is contained in:
parent
cd4f5985e4
commit
c48b82148a
|
@ -16,6 +16,14 @@ export interface HeroPartProps {
|
||||||
searchParams: ReturnType<typeof useSearchQuery>;
|
searchParams: ReturnType<typeof useSearchQuery>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTimeOfDay(date: Date): "night" | "morning" | "day" {
|
||||||
|
const hour = date.getHours();
|
||||||
|
if (hour < 5) return "night";
|
||||||
|
if (hour < 12) return "morning";
|
||||||
|
if (hour < 19) return "day";
|
||||||
|
return "night";
|
||||||
|
}
|
||||||
|
|
||||||
export function HeroPart({ setIsSticky, searchParams }: HeroPartProps) {
|
export function HeroPart({ setIsSticky, searchParams }: HeroPartProps) {
|
||||||
const { t: randomT } = useRandomTranslation();
|
const { t: randomT } = useRandomTranslation();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -44,11 +52,7 @@ export function HeroPart({ setIsSticky, searchParams }: HeroPartProps) {
|
||||||
}
|
}
|
||||||
}, [windowWidth]);
|
}, [windowWidth]);
|
||||||
|
|
||||||
let time = "night";
|
const time = getTimeOfDay(new Date());
|
||||||
const hour = new Date().getHours();
|
|
||||||
if (hour < 12) time = "morning";
|
|
||||||
else if (hour < 19) time = "day";
|
|
||||||
|
|
||||||
const title = randomT(`home.titles.${time}`);
|
const title = randomT(`home.titles.${time}`);
|
||||||
|
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
Loading…
Reference in a new issue