/** * @param $table_column * @param $nice_name * @param $nullable * @param null $default_value * @param null $timezone * @param null $date_format * @param null $time_format * @param null $pretty_date_format * @param null $pretty_time_format */ public function __construct($table_column, $nice_name, $nullable, $default_value, $timezone = NULL, $date_format = NULL, $time_format = NULL, $pretty_date_format = NULL, $pretty_time_format = NULL) { parent::__construct($table_column, $nice_name, $nullable, $default_value); $this->_date_format = empty($date_format) ? get_option('date_format') : $date_format; $this->_date_format = EE_Base_Class::fix_date_format_for_use_with_strtotime($this->_date_format); $this->_time_format = empty($time_format) ? get_option('time_format') : $time_format; $this->set_timezone($timezone); $this->_pretty_date_format = empty($pretty_date_format) ? get_option('date_format') : $pretty_date_format; $this->_pretty_date_format = EE_Base_Class::fix_date_format_for_use_with_strtotime($this->_pretty_date_format); $this->_pretty_time_format = empty($pretty_time_format) ? get_option('time_format') : $pretty_time_format; }
/** * This simply returns the datetime for the given field name * Note: this protected function is called by the wrapper get_date or get_time or get_datetime functions (and the equivalent e_date, e_time, e_datetime). * * @access protected * @param string $field_name Field on the instantiated EE_Base_Class child object * @param null $dt_frmt valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format) * @param null $tm_frmt Same as above except this is for time format * @param string $date_or_time if NULL then both are returned, otherwise "D" = only date and "T" = only time. * @param boolean $echo Whether the dtt is echoing using pretty echoing or just returned using vanilla get * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing */ protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) { $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : EE_Base_Class::fix_date_format_for_use_with_strtotime($dt_frmt); $in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt; //validate field for datetime and returns field settings if valid. $field = $this->_get_dtt_field_settings($field_name); if ($dt_frmt !== NULL) { $this->_clear_cached_property($field_name, $date_or_time); } if ($echo) { $field->set_pretty_date_format($in_dt_frmt); } else { $field->set_date_format($in_dt_frmt); } if ($tm_frmt !== NULL) { $this->_clear_cached_property($field_name, $date_or_time); } if ($echo) { $field->set_pretty_time_format($in_tm_frmt); } else { $field->set_time_format($in_tm_frmt); } //set timezone in field object $field->set_timezone($this->_timezone); //set the output returned switch ($date_or_time) { case 'D': $field->set_date_time_output('date'); break; case 'T': $field->set_date_time_output('time'); break; default: $field->set_date_time_output(); } if ($echo) { $this->e($field_name, $date_or_time); return ''; } return $this->get($field_name, $date_or_time); }