diff options
| author | Patrick Seeger <pseeger@ccwn.org> | 2012-05-11 10:18:31 +0200 |
|---|---|---|
| committer | Patrick Seeger <pseeger@ccwn.org> | 2012-05-11 10:18:31 +0200 |
| commit | a6cd00ec233d1c7676d75224900ed1543130ac94 (patch) | |
| tree | 94f25ab6433d3a729e004dbc2610e3f7b7c69cc2 /protected/components/Format.php | |
| parent | 5b39d6bf7f34ed52059410f3d0af3799aeff2113 (diff) | |
diverse anzeigen und experimente
Diffstat (limited to '')
| -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 |
