Пример #1
0
 public static function formatCompactAddress($data, $locale = null)
 {
     if (!isset($locale)) {
         $locale = Locale::getLocale();
     }
     $i18n = new I18n();
     return self::_formatAddress($i18n->getAddressFormat($locale), $data, ' - ');
 }
Пример #2
0
 public function getWeekDayNames($type = 'wide', $locale = null, $standAlone = false)
 {
     if (!isset($locale)) {
         $locale = Locale::getLocale();
     }
     $resource = $this->getResource($locale);
     if ($standAlone) {
         return isset($resource['weekDayNamesSA'][strtolower($type)]) ? $resource['weekDayNamesSA'][strtolower($type)] : $resource['weekDayNames'][strtolower($type)];
     } else {
         return isset($resource['weekDayNames'][strtolower($type)]) ? $resource['weekDayNames'][strtolower($type)] : $resource['weekDayNamesSA'][strtolower($type)];
     }
 }
Пример #3
0
 protected static function formatDayInWeek($pattern, $date, $locale = null)
 {
     if (!isset($locale)) {
         $locale = Locale::getLocale();
     }
     $i18n = new I18n();
     $day = $date->getWeekDay();
     switch ($pattern) {
         case 'E':
         case 'EE':
         case 'EEE':
         case 'eee':
             return $i18n->getWeekDayName($day, 'abbreviated', $locale);
         case 'EEEE':
         case 'eeee':
             return $i18n->getWeekDayName($day, 'wide', $locale);
         case 'EEEEE':
         case 'eeeee':
             return $i18n->getWeekDayName($day, 'narrow', $locale);
         case 'e':
         case 'ee':
         case 'c':
             return $day ? $day : 7;
         case 'ccc':
             return $i18n->getWeekDayName($day, 'abbreviated', $locale, true);
         case 'cccc':
             return $i18n->getWeekDayName($day, 'wide', $locale, true);
         case 'ccccc':
             return $i18n->getWeekDayName($day, 'narrow', $locale, true);
         default:
             throw new \RuntimeException('The pattern for day of the week' . ' must be "E", "EE", "EEE", "EEEE", "EEEEE", "e", "ee",' . ' "eee", "eeee", "eeeee", "c", "cccc" or "ccccc".');
     }
 }