getCurrency
git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@40 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
@ -2,8 +2,8 @@
|
|||||||
/**
|
/**
|
||||||
* Format
|
* Format
|
||||||
*
|
*
|
||||||
* @copyright
|
* @copyright
|
||||||
* @link
|
* @link
|
||||||
* @package Majestic
|
* @package Majestic
|
||||||
* @subpackage Core
|
* @subpackage Core
|
||||||
* @since 24.12.2008
|
* @since 24.12.2008
|
||||||
@ -12,34 +12,38 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Отвечает за конвертацию данных между читаемым
|
* Отвечает за конвертацию данных между читаемым
|
||||||
* человеком и машиной форматами.
|
* человеком и машиной форматами.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Format
|
class Format
|
||||||
{
|
{
|
||||||
/* Date & time */
|
/* Date & time */
|
||||||
static protected $time_format = 'H:i:s';
|
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 $date_time_format = 'd.m.Y H:i';
|
||||||
static protected $timezone_offset = 0;
|
static protected $timezone_offset = 0;
|
||||||
static protected $cache_time = array();
|
static protected $cache_time = array();
|
||||||
|
|
||||||
/* money */
|
/* money */
|
||||||
static protected $decimal_point = ',';
|
static protected $decimal_point = ',';
|
||||||
static protected $currency_symbol = ' руб.';
|
static protected $currency_symbol = 'руб.';
|
||||||
static protected $frac_digits = 2;
|
static protected $frac_digits = 2;
|
||||||
static protected $cache_money = array();
|
static protected $cache_money = array();
|
||||||
|
|
||||||
|
static public function getCurrency()
|
||||||
|
{
|
||||||
|
return self::$currency_symbol;
|
||||||
|
}
|
||||||
|
|
||||||
static public function int2money($int = 0, $currency = false)
|
static public function int2money($int = 0, $currency = false)
|
||||||
{
|
{
|
||||||
if(!isset(self::$cache_money[$int])){
|
if(!isset(self::$cache_money[$int])){
|
||||||
self::$cache_money[$int] = number_format($int/100, self::$frac_digits, self::$decimal_point, '');
|
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)
|
static public function money2int($money)
|
||||||
{
|
{
|
||||||
if(!isset(self::$cache_money[$money])){
|
if(!isset(self::$cache_money[$money])){
|
||||||
@ -47,11 +51,11 @@ class Format
|
|||||||
}
|
}
|
||||||
return self::$cache_money[$money];
|
return self::$cache_money[$money];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Возвращает время в часах из секунд.
|
* Возвращает время в часах из секунд.
|
||||||
*
|
*
|
||||||
* @param int $timestamp
|
* @param int $timestamp
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -62,10 +66,10 @@ class Format
|
|||||||
}
|
}
|
||||||
return self::$cache_time[$timestamp];
|
return self::$cache_time[$timestamp];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Возвращает дату и время из таймстампа.
|
* Возвращает дату и время из таймстампа.
|
||||||
*
|
*
|
||||||
* @param int $timestamp
|
* @param int $timestamp
|
||||||
* @param bool $hours
|
* @param bool $hours
|
||||||
* @return string
|
* @return string
|
||||||
@ -77,20 +81,20 @@ class Format
|
|||||||
}
|
}
|
||||||
return self::$cache_time[$timestamp];
|
return self::$cache_time[$timestamp];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Установка смещения для getTime
|
* Установка смещения для getTime
|
||||||
*
|
*
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
*/
|
*/
|
||||||
static public function setTimezoneOffset($offset)
|
static public function setTimezoneOffset($offset)
|
||||||
{
|
{
|
||||||
self::$timezone_offset = $offset;
|
self::$timezone_offset = $offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Преобразует время в секунды.
|
* Преобразует время в секунды.
|
||||||
*
|
*
|
||||||
* @param string $time
|
* @param string $time
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@ -107,10 +111,10 @@ class Format
|
|||||||
}
|
}
|
||||||
return self::$cache_time[$time];
|
return self::$cache_time[$time];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Преобразует дату в таймстамп.
|
* Преобразует дату в таймстамп.
|
||||||
*
|
*
|
||||||
* @param mixed $time
|
* @param mixed $time
|
||||||
* @return TimeFormat
|
* @return TimeFormat
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user