date support, global object checking, small fix

support Date type
throw exception if global object is passed
fix a not defined error