1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<?php
class Format {
public static function currency($value, $currency = 'EUR') {
if ($value <=0) { return "?,?? 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;
}
public static function displayDateForLists($value) {
if(Yii::app()->dateFormatter->format('HH',$value->startzeit) < 4)
{
return "<strong>".Yii::app()->dateFormatter->format('EEEE',$value->startzeit)."</strong><br />".
Yii::app()->dateFormatter->format('HH:mm',$value->startzeit)." Uhr";
} else{
return Yii::app()->dateFormatter->format('HH:mm',$value->startzeit)." Uhr";
}
}
}
|