|
|
@ -2,8 +2,8 @@ |
|
|
|
/** |
|
|
|
* Format |
|
|
|
* |
|
|
|
* @copyright |
|
|
|
* @link |
|
|
|
* @copyright |
|
|
|
* @link |
|
|
|
* @package Majestic |
|
|
|
* @subpackage Core |
|
|
|
* @since 24.12.2008 |
|
|
@ -12,34 +12,38 @@ |
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* Отвечает за конвертацию данных между читаемым |
|
|
|
* Отвечает за конвертацию данных между читаемым |
|
|
|
* человеком и машиной форматами. |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
class Format |
|
|
|
{ |
|
|
|
/* Date & time */ |
|
|
|
static protected $time_format = 'H:i:s'; |
|
|
|
static protected $date_format = 'd.m.Y'; |
|
|
|
static protected $date_format = 'd.m.Y'; |
|
|
|
static protected $date_time_format = 'd.m.Y H:i'; |
|
|
|
static protected $timezone_offset = 0; |
|
|
|
static protected $cache_time = array(); |
|
|
|
|
|
|
|
|
|
|
|
/* money */ |
|
|
|
static protected $decimal_point = ','; |
|
|
|
static protected $currency_symbol = ' руб.'; |
|
|
|
static protected $currency_symbol = 'руб.'; |
|
|
|
static protected $frac_digits = 2; |
|
|
|
static protected $cache_money = array(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public function getCurrency() |
|
|
|
{ |
|
|
|
return self::$currency_symbol; |
|
|
|
} |
|
|
|
|
|
|
|
static public function int2money($int = 0, $currency = false) |
|
|
|
{ |
|
|
|
if(!isset(self::$cache_money[$int])){ |
|
|
|
self::$cache_money[$int] = number_format($int/100, self::$frac_digits, self::$decimal_point, ''); |
|
|
|
} |
|
|
|
return self::$cache_money[$int] . (($currency) ? self::$currency_symbol : ''); |
|
|
|
return self::$cache_money[$int] . (($currency) ? ' '.self::$currency_symbol : ''); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static public function money2int($money) |
|
|
|
{ |
|
|
|
if(!isset(self::$cache_money[$money])){ |
|
|
@ -47,11 +51,11 @@ class Format |
|
|
|
} |
|
|
|
return self::$cache_money[$money]; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Возвращает время в часах из секунд. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param int $timestamp |
|
|
|
* @return string |
|
|
|
*/ |
|
|
@ -62,10 +66,10 @@ class Format |
|
|
|
} |
|
|
|
return self::$cache_time[$timestamp]; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Возвращает дату и время из таймстампа. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param int $timestamp |
|
|
|
* @param bool $hours |
|
|
|
* @return string |
|
|
@ -77,20 +81,20 @@ class Format |
|
|
|
} |
|
|
|
return self::$cache_time[$timestamp]; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Установка смещения для getTime |
|
|
|
* |
|
|
|
* |
|
|
|
* @param int $offset |
|
|
|
*/ |
|
|
|
static public function setTimezoneOffset($offset) |
|
|
|
{ |
|
|
|
self::$timezone_offset = $offset; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Преобразует время в секунды. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param string $time |
|
|
|
* @return int |
|
|
|
*/ |
|
|
@ -107,10 +111,10 @@ class Format |
|
|
|
} |
|
|
|
return self::$cache_time[$time]; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Преобразует дату в таймстамп. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param mixed $time |
|
|
|
* @return TimeFormat |
|
|
|
*/ |
|
|
|