I have a function here that attempts to return true if the current time is between two military times.
The issue here is finding a time between 2130 and 0700 is a little tricky. The 2130 works fine, but 0700 is before 2130, so it returns false here. How can I get this to return true?
Just switch the && to a ||?
public bool IsSleeping()
{
DateTime m_dt = DateTime.Now;
string strMilitaryTime;
int time;
strMilitaryTime = m_dt.ToString("HHmm"); // Get current military time
time = Convert.ToInt32(strMilitaryTime); // Convert to int
// The time must be between sleeping hours of 2400 and 0700.
if (time >= 2130 && time < 700)
return true;
return false;
}