Keep zero



  • One of my favorites (of many) from an app my team maintains (but didn't write):


    RightNow = DateAdd("h", Convert.ToDouble(randomObject.GetAppSetting("TimeOffset")), Now())

    And elsewhere....

    TimeSpan span = new TimeSpan(Convert.ToInt64(randomObject.GetAppSetting("TimeOffset")));
    RightNow = DateTime.Now.Add(span);
    AYearFromNow = RightNow.AddYears(1);


    And TimeOffset in the config file?

    <!-- Keep zero-->
    <add key="TimeOffset" value="0"/>


    (In addition to all the date WTFs, GetAppSetting of course is an instance method found in multiple business "objects"--and I use the word object very losely--across the application). Some variable names changed but everything else left exactly as is.


  • try{

       RightNow = DateTime.Now.AddDays(1); // It's your tomorrow.

       Wait("for what");

    } catch ThatMagicMoment {

       ThatMagicMoment && DoItRight();

    }



  • Perhaps it was there for unit testing - if you want to test weird cases like leap-days and stuff, you don't want to have to wait four years or fiddle with the system clock!



  •  very losely


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.