Code that Works
by in Coded Smorgasbord on 2014-02-25The first step to working with dates is to learn when to use the built in APIs. The second step is to learn how to do basic arithmetic, as Ron shows us.
if (wishDate.Hour < 10)
{
while (wishDate.Hour < 10)
{
wishDate = wishDate.AddHours(1);
}
}
else if (wishDate.Hour > 16)
{
while (wishDate.Hour > 16)
{
wishDate = wishDate.AddHours(-1);
}
}