Recent Coded Smorgasbord

Inspired by the Pop-up Potpourri, the examples presented here aren't necessarily "bad" code nor do they imply the miserable failure that we're all used to reading here. The examples are more-or-less fun snippets of code like ones that we've all written at one time or another.

Feb 2014

Code that Works

by in Coded Smorgasbord on

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