A huge number of the bad code submitted to TDWTF is related to dates. This isn’t all that surprising- dates are very complex data structures with a vast number of possible representations and huge cultural variations.

I have no idea what the excuse is for all the bad code relating to booleans. Today, let's take a moment to explore some philosophy, and see if we can understand what truth really is.

Adam shares this JavaScript helper function:

Boolean.prototype.isTrue = function () {
  if (this == true) {
     return true;
  } else if (this === true) {
     return true;
  } else {
     return false;
  }
}

JavaScript does have a fairly confusing system for managing booleans, and this code was obviously written by someone who didn’t want to understand it.

Carol provided us this eerily similar snippet. Perhaps the same developer moved into server side programming?

public class BooleanUtilities
    {
        public function BooleanUtilities()
        {
        }

        public function isTrue(arg:Boolean):Boolean
        {
            if (arg)
            {
                return true;
            } else {
                return false;
            }
        }

        public function isFalse(arg:Boolean):Boolean
        {
            if (!arg)
            {
                return true;
            } else {
                return false;
            }
        }
        
        public function formatZeroOne(arg:Number):Boolean
        {
            if (arg == 0)
            {
                return false;
            } else {
                return true;
            }
        }
    }

Each time this program calls new BooleanUtilities().isTrue(val) a baby lemur cries.

And in our final exploration of what truth truly is , Pauli provides us with yet another variation on the old FileNotFound.

public class types
{
   public enum bool
   {

       TRUE, FALSE, UNDEF, SIM
   }
}