I am not sure, but trying to put you in the right direction... 2 thoughts.
1 - At first sight, there may be an inconstistancy.. you take the TimeZoneOffset into consideration when getting start and endtime, but you dont when you get $now
so you might (not at all sure) have to add the the...