Hello to all experts, I am encountering some "time" function problem, and will be greatly appreciated if someone can help me with it

IN ASSUMPTION OF:
A1 - starting time
B1 - ending time

What is the right equation to use to
1) Categorize the time zone into two groups (? cluster? stratums?)
1.1) 7:00am ~7:00pm = morning
1.2) 7:01pm~ 6:59am = night

2) Capable of concluding from A1 & B1 :
2.1) Total Hours (this is solved)
2.2) Within the given time period, how many hours are in "morning"
2.3) Within the given time period, how many hours are in "night"

=====================

For example,
Leo works from 7 AM (A1) to 10 PM(B1)

the system is capable of recognizing :
1) Leo has worked 15 hours
1.1) 12 hours in morning <<as 7am ~ 7pm = morning>>
1.2) 3 hours at night <<as 7:01pm ~ 6:59am = night>>


Thank you!!