Fix time of day calculation logic

Previously between 00:00 - 04:00 it'd trigger afternoon insteead of
evening
This commit is contained in:
Debanjum Singh Solanky 2024-08-04 04:53:50 +05:30
parent 015c155582
commit 692058bbdd

View file

@ -59,7 +59,7 @@ function ChatBodyData(props: ChatBodyDataProps) {
// Get today's day
const today = new Date();
const day = today.getDay();
const timeOfDay = today.getHours() > 4 && today.getHours() < 12 ? 'morning' : today.getHours() < 17 ? 'afternoon' : 'evening';
const timeOfDay = today.getHours() >= 17 || today.getHours() < 4 ? 'evening' : today.getHours() >= 12 ? 'afternoon' : 'morning';
const nameSuffix = props.userConfig?.given_name ? `, ${props.userConfig?.given_name}` : "";
const greetings = [
`What would you like to get done${nameSuffix}?`,