The 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);
   }
}

Now, maybe you know enough arithmetic to calculate differences without while loops. Are you clever enough to turn a positive number into a negative value with equal magnitude? Carl found this bit of code.

// has to be a negative value
if (discountTotal > 0)
{
 discountTotal = discountTotal - (discountTotal * 2);  
}

Maybe math just isn’t our strong suit. What about string manipulation? Can you chop the protocol section off a URL? Christopher sends this gem our way.

auth_server = auth_server_url.reverse.chomp('http://'.reverse).reverse.reverse.chomp('https://'.reverse).reverse