format('U') + $dto->getOffset(); $text = date_i18n($format,$timestamp); return $text; } function amru_new_DateTime_nonfatal ($datetimestring='', $tzobj) { // date time create with exception trap to avoid fatal errors try { $dt = new DateTime($datetimestring); $dt->setTimezone($tzobj); } catch(Exception $e) { if (current_user_can('manage_options') or current_user_can('manage_userlists')) { echo '
' .__('Message to admin only:','amr-users').' ' .__('Fatal error caught','amr-users').' - '. sprintf(__('Unable to create DateTime object from this string: "%s" ','amr-users'),$datetimestring).' ' .__('Please check the content of your date fields, and any fields where you have specified a date format','amr-users').'
'; } //else fail silently return (false); } return ($dt); } function amru_newDateTime($text='') { // create new datetime object with the global timezone // because wordpress insists that the php default must stay as UTC global $tzobj; if (empty($tzobj)) $tzobj = amr_getset_timezone (); $d = amru_new_DateTime_nonfatal($text,$tzobj); // traps exceptions return ($d); } function amru_get_func_name ($fld, $format) { global $amr_users_field_types; if (empty($amr_users_field_types)) // to get the type of field $amr_users_field_types = ausers_get_option('amr-users-field-types'); if (empty($amr_users_field_types[$fld])) return false; // no defined fieldtype else $type = $amr_users_field_types[$fld]; $func = 'ausers_format_'.$type.'_'.$format; return $func; } function amr_is_assoc($array) { return (bool)count(array_filter(array_keys($array), 'is_string')); } function amr_debug() { if (WP_DEBUG and is_user_logged_in() and current_user_can('activate_plugins')) { return true; } else return false; } function amr_debug_no_such_list () { // called when the list searched for is not found in db option. global $aopt, $amain; if (empty($aopt)) { echo '