/** * DateTime Constructor * * create a Cast object from a Date/Time * Maybe should accept a Date object.! * NO VALIDATION DONE, although some crappy re-calcing done! * * @param vargs... accepts * noargs (now) * yyyy-mm-dd HH:MM:SS (Iso) * array(yyyy,mm,dd,HH,MM,SS) * * * @return object DB_DataObject2_Cast * @access public * @author therion 5 at hotmail */ public static function dateTime() { $args = func_get_args(); switch (count($args)) { case 0: // no args = now! $datetime = date('Y-m-d G:i:s', mktime()); case 1: // continue on from 0 args. if (!isset($datetime)) { $datetime = $args[0]; } $parts = explode(' ', $datetime); $bits = explode('-', $parts[0]); $bits = array_merge($bits, explode(':', $parts[1])); break; default: // 2 or more.. $bits = $args; } if (count($bits) != 6) { // PEAR ERROR? return false; } $r = DB_DataObject2_Cast::date($bits[0], $bits[1], $bits[2]); if (!$r) { return $r; // pass thru error (False) - doesnt happen at present! } // change the type! $r->type = 'datetime'; // should we mathematically sort this out.. // (or just assume that no-one's dumb enough to enter 26:90:90 as a time! $r->hour = $bits[3]; $r->minute = $bits[4]; $r->second = $bits[5]; return $r; }