/** * Создаёт объект-дату по строке вида «20131115153657». * @param string $timestamp * @param string|null $offsetType [optional] * @return ZD */ function df_date_from_timestamp_14($timestamp, $offsetType = null) { df_assert(ctype_digit($timestamp)); df_assert_eq(14, strlen($timestamp)); // Почему-то new Zend_Date($timestamp, 'yMMddHHmmss') у меня не работает /** @var string $pattern */ $pattern = '#(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})#'; /** @var int[] $matches */ $matches = []; /** @var int $r */ $r = preg_match($pattern, $timestamp, $matches); df_assert_eq(1, $r); /** @var int $hour */ $hour = df_nat0(dfa($matches, 4)); if ($offsetType) { df_assert_in($offsetType, ['UTC', 'GMT']); /** @var int $offsetFromGMT */ $offsetFromGMT = df_round(df_int(df_dts(ZD::now(), ZD::TIMEZONE_SECS)) / 3600); $hour += $offsetFromGMT; if ('UTC' === $offsetType) { $hour++; } } return new ZD(['year' => dfa($matches, 1), 'month' => dfa($matches, 2), 'day' => dfa($matches, 3), 'hour' => $hour, 'minute' => dfa($matches, 5), 'second' => dfa($matches, 6)]); }
/** * @override * @param mixed $value * @throws \Zend_Filter_Exception * @return int */ public function filter($value) { /** @var int $result */ try { $result = df_int($value, $allowNull = true); } catch (\Exception $e) { df_error(new \Zend_Filter_Exception(df_ets($e))); } return $result; }
/** * 2016-01-29 * @param AE|E $e * @param string $key * @param int|null|callable $default [optional] * @return int */ function df_fe_fc_i(AE $e, $key, $default = 0) { return df_int(df_fe_fc($e, $key, $default)); }
/** @return int */ private function getNumberIntegerPart() { return df_int($this->getNumber()); }
/** * @param $colorS * @return int[] */ private function rgb($colorS) { return df_int(explode('|', $colorS)); }
/** * 2015-11-09 * @param string|null $key [optional] * @param null|string|int|S|Store $s [optional] * @return int */ public function i($key = null, $s = null) { return df_int($this->v($key ?: df_caller_f(), $s)); }
/** * 2015-10-12 * @param string $table * @return int */ function df_next_increment_old($table) { /** @var Select $select */ $select = df_select()->from('information_schema.tables', 'AUTO_INCREMENT'); $select->where('? = table_name', $table); $select->where('? = table_schema', df_db_name()); return df_int(df_first(df_conn()->fetchCol($select, 'AUTO_INCREMENT'))); }
/** * 2015-11-29 * @uses dechex() * http://php.net/manual/function.dechex.php * http://stackoverflow.com/a/15202156 * @param int[] $rgb * @param string $prefix [optional] * @return string */ function df_rgb2hex(array $rgb, $prefix = '') { return $prefix . df_pad0(6, implode(array_map('dechex', df_int($rgb)))); }
/** * 2015-08-16 * Намеренно убрал параметр $default. * @param CX|null $e [optional] * @return int */ function df_leaf_i(CX $e = null) { return df_int(df_leaf($e)); }
/** * @param mixed $v * @param bool $allow0 [optional] * @return int * @throws DFE */ function df_nat($v, $allow0 = false) { /** @var int $result */ $result = df_int($v, $allow0); if ($allow0) { df_assert_ge(0, $result); } else { df_assert_gt0($result); } return $result; }
/** * @param string|null $s * @return int[] */ function df_csv_parse_int($s) { return df_int(df_csv_parse($s)); }