throw new CException(Yii::t('yii','The pattern for day of the week must be "E", "EE", "EEE", "EEEE", "EEEEE", "e", "ee", "eee", "eeee", "eeeee", "c", "cccc" or "ccccc".'));
}
}
/**
* Get the AM/PM designator, 12 noon is PM, 12 midnight is AM.
* @param string $pattern a pattern.
* @param array $date result of {@link CTimestamp::getdate}.
* @return string AM or PM designator
*/
protected function formatPeriod($pattern,$date)
{
if($pattern==='a')
{
if(intval($date['hours']/12))
return $this->_locale->getPMName();
else
return $this->_locale->getAMName();
}
else
throw new CException(Yii::t('yii','The pattern for AM/PM marker must be "a".'));
}
/**
* Get the hours in 24 hour format, i.e. [0-23].
* "H" for non-padding, "HH" will always return 2 characters.
* @param string $pattern a pattern.
* @param array $date result of {@link CTimestamp::getdate}.
* @return string hours in 24 hour format.
*/
protected function formatHour24($pattern,$date)
{
$hour=$date['hours'];
if($pattern==='H')
return $hour;
else if($pattern==='HH')
return str_pad($hour,2,'0',STR_PAD_LEFT);
else
throw new CException(Yii::t('yii','The pattern for 24 hour format must be "H" or "HH".'));
}
/**
* Get the hours in 12 hour format, i.e., [1-12]
* "h" for non-padding, "hh" will always return 2 characters.
* @param string $pattern a pattern.
* @param array $date result of {@link CTimestamp::getdate}.
* @return string hours in 12 hour format.
*/
protected function formatHour12($pattern,$date)
{
$hour=$date['hours'];
$hour=($hour==12|$hour==0)?12:($hour)%12;
if($pattern==='h')
return $hour;
else if($pattern==='hh')
return str_pad($hour,2,'0',STR_PAD_LEFT);
else
throw new CException(Yii::t('yii','The pattern for 12 hour format must be "h" or "hh".'));
}
/**
* Get the hours [1-24].
* 'k' for non-padding, and 'kk' with 2 characters padding.
* @param string $pattern a pattern.
* @param array $date result of {@link CTimestamp::getdate}.
* @return integer hours [1-24]
*/
protected function formatHourInDay($pattern,$date)
{
$hour=$date['hours']==0?24:$date['hours'];
if($pattern==='k')
return $hour;
else if($pattern==='kk')
return str_pad($hour,2,'0',STR_PAD_LEFT);
else
throw new CException(Yii::t('yii','The pattern for hour in day must be "k" or "kk".'));
}
/**
* Get the hours in AM/PM format, e.g [0-11]
* "K" for non-padding, "KK" will always return 2 characters.
* @param string $pattern a pattern.
* @param array $date result of {@link CTimestamp::getdate}.
* @return integer hours in AM/PM format.
*/
protected function formatHourInPeriod($pattern,$date)
{
$hour=$date['hours']%12;
if($pattern==='K')
return $hour;
else if($pattern==='KK')
return str_pad($hour,2,'0',STR_PAD_LEFT);
else
throw new CException(Yii::t('yii','The pattern for hour in AM/PM must be "K" or "KK".'));
}
/**
* Get the minutes.
* "m" for non-padding, "mm" will always return 2 characters.
* @param string $pattern a pattern.
* @param array $date result of {@link CTimestamp::getdate}.
* @return string minutes.
*/
protected function formatMinutes($pattern,$date)
{
$minutes=$date['minutes'];
if($pattern==='m')
return $minutes;
else if($pattern==='mm')
return str_pad($minutes,2,'0',STR_PAD_LEFT);
else
throw new CException(Yii::t('yii','The pattern for minutes must be "m" or "mm".'));
}
/**
* Get the seconds.
* "s" for non-padding, "ss" will always return 2 characters.
* @param string $pattern a pattern.
* @param array $date result of {@link CTimestamp::getdate}.
* @return string seconds
*/
protected function formatSeconds($pattern,$date)
{
$seconds=$date['seconds'];
if($pattern==='s')
return $seconds;
else if($pattern==='ss')
return str_pad($seconds,2,'0',STR_PAD_LEFT);
else
throw new CException(Yii::t('yii','The pattern for seconds must be "s" or "ss".'));
}
/**
* Get the week in the year.
* @param string $pattern a pattern.
* @param array $date result of {@link CTimestamp::getdate}.
* @return integer week in year
*/
protected function formatWeekInYear($pattern,$date)