diff options
| author | Patrick Seeger <pseeger@ccwn.org> | 2012-04-30 10:18:11 +0200 |
|---|---|---|
| committer | Patrick Seeger <pseeger@ccwn.org> | 2012-04-30 10:18:11 +0200 |
| commit | acec2b5dc35302147f9a9c73d837dce2f3f9958e (patch) | |
| tree | 2f88a3a657a9211331e1e63e056a089189bd0dd2 /protected/components/Format.php | |
| parent | 56593a21209f3ce55fe66d303dbe01b8e081778b (diff) | |
| parent | 148a216bba21cec1cbe07b60b5191791e0016d6f (diff) | |
Merge branch 'master' of ssh://proxy.ccwn.org:9044/home/ccwn/git-repos/admin.astaf.de
Diffstat (limited to 'protected/components/Format.php')
| -rw-r--r-- | protected/components/Format.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/protected/components/Format.php b/protected/components/Format.php new file mode 100644 index 0000000..1be259f --- /dev/null +++ b/protected/components/Format.php @@ -0,0 +1,35 @@ +<?php +class Format { + public static function currency($value, $currency = 'EUR') { + return Yii::app()->locale->numberFormatter->formatCurrency($value, $currency); + } + + public static function number($value, $einheit = '') { + return Yii::app()->locale->numberFormatter->formatDecimal($value).' '.$einheit; + } + + public static function decimal($value) { + return Yii::app()->locale->numberFormatter->formatDecimal($value); + } + + public static function percentage($value) { + return Yii::app()->locale->numberFormatter->formatPercentage($value); + } + + public static function dbDateTime($value) { + return Yii::app()->dateFormatter->format('yyyy-MM-dd HH:mm', CDateTimeParser::parse($value, 'dd.MM.yyyy HH:mm')); + } + + public static function displayDateTime($value) { + $checkvalue = CDateTimeParser::parse($value, 'dd.MM.yyyy HH:mm'); + if (!empty($checkvalue)) { + return $value; + } + $timestamp = CDateTimeParser::parse($value, 'yyyy-MM-dd HH:mm:ss'); + Yii::trace('Input value: '.$value. ' -> output timestamp: '.$timestamp, 'ccwn.astaf.format'); + if ($timestamp) { + return Yii::app()->dateFormatter->format('dd.MM.yyyy HH:mm', $timestamp); + } + return null; + } +}
\ No newline at end of file |
