Time can be a bit difficult the first time you need to think about it. Part of the problem is that there are some major time concepts that people try to ignore in software, and then find they can't.
First off, there's the concept of absolute time. This is a timestamp that represents an instant in time, whenever - be it 2010 BC March 14 at 3:15:26, or whatever.
Then there's the concept of a time interval. For instance, 1989 represents the entire year 1989 from 00:00:00 on January 01 through 23:59:59.99999 on December 31.
Which is different from the concept of an absolute time difference, say 17:15:00, which would be seventeen hours, fifteen minutes. Time differences can be positive or negative.
Then there's the concept of the indeterminate time difference. One month's difference means what? On February first, adding one month should give March first, right? So it's 28 (or 29) days. But on December first, one months difference is 31 days.
In your context the values you're recieving are exact time differences. Which means that they can be added together in a sensible sort of way.
Likewise, 4.45pm is also an exact time difference. It's the common form of expressing a time difference relative to the start of a day.
Exact time differences can be directly compared without having to worry about little things like time period overlap and all that mess.
But you probably don't care. Just convert the entire input mess to relative hours and test, like follows:
- float zeit=hours+(float)minutes/60.0;
-
boolean re=(zeit<16.75);
-
return re;
Or, if you prefer, do it in minutes.
- int d=minutes+hours*60;
-
boolean r=(1005>d);
-
return r;
Sorry for being so short, it's just that I've taken headers into time issues on occasion, and most folks just don't seem to understand the issues and the assumptions that we make when we deal with time in our day-to-day lives.
Just wait until you have somebody ask for timestamps and then just say "duh?" when you mention the fact that their web site is 24/7 worldwide, so what time zone...Oh yes, and what's this 22:00 business - it's only 3:00pm.