当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Locale_Format::getTimeFormat方法代码示例

本文整理汇总了PHP中Zend_Locale_Format::getTimeFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Locale_Format::getTimeFormat方法的具体用法?PHP Zend_Locale_Format::getTimeFormat怎么用?PHP Zend_Locale_Format::getTimeFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Locale_Format的用法示例。


在下文中一共展示了Zend_Locale_Format::getTimeFormat方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: install_locale

 /**
  * Set/Install the given locale.
  * This does set the i18n locale as well as the Translatable or Fluent locale (if any of these modules is installed)
  * @param string $locale the locale to install
  * @throws Zend_Locale_Exception @see Zend_Locale_Format::getDateFormat and @see Zend_Locale_Format::getTimeFormat
  */
 public static function install_locale($locale)
 {
     // If the locale isn't given, silently fail (there might be carts that still have locale set to null)
     if (empty($locale)) {
         return;
     }
     if (class_exists('Translatable')) {
         Translatable::set_current_locale($locale);
     } else {
         if (class_exists('Fluent')) {
             Fluent::set_persist_locale($locale);
         }
     }
     // Do something like Fluent does to install the locale
     i18n::set_locale($locale);
     // LC_NUMERIC causes SQL errors for some locales (comma as decimal indicator) so skip
     foreach (array(LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_TIME) as $category) {
         setlocale($category, "{$locale}.UTF-8", $locale);
     }
     // Get date/time formats from Zend
     require_once 'Zend/Date.php';
     i18n::config()->date_format = Zend_Locale_Format::getDateFormat($locale);
     i18n::config()->time_format = Zend_Locale_Format::getTimeFormat($locale);
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:30,代码来源:ShopTools.php

示例2: getCMSFields

 /**
  * Return a {@link FieldSet} of fields that would appropriate for editing
  * this member.
  *
  * @return FieldSet Return a FieldSet of fields that would appropriate for
  *                  editing this member.
  */
 public function getCMSFields()
 {
     require_once 'Zend/Date.php';
     $fields = parent::getCMSFields();
     $mainFields = $fields->fieldByName("Root")->fieldByName("Main")->Children;
     $password = new ConfirmedPasswordField('Password', null, null, null, true);
     $password->setCanBeEmpty(true);
     if (!$this->ID) {
         $password->showOnClick = false;
     }
     $mainFields->replaceField('Password', $password);
     $mainFields->insertBefore(new HeaderField('MemberDetailsHeader', _t('Member.PERSONALDETAILS', "Personal Details", PR_MEDIUM, 'Headline for formfields')), 'FirstName');
     $mainFields->insertBefore(new HeaderField('MemberUserDetailsHeader', _t('Member.USERDETAILS', "User Details", PR_MEDIUM, 'Headline for formfields')), 'Email');
     $mainFields->replaceField('Locale', new DropdownField("Locale", _t('Member.INTERFACELANG', "Interface Language", PR_MEDIUM, 'Language of the CMS'), i18n::get_existing_translations()));
     $mainFields->removeByName('Bounced');
     $mainFields->removeByName('RememberLoginToken');
     $mainFields->removeByName('AutoLoginHash');
     $mainFields->removeByName('AutoLoginExpired');
     $mainFields->removeByName('PasswordEncryption');
     $mainFields->removeByName('PasswordExpiry');
     $mainFields->removeByName('LockedOutUntil');
     if (!self::$lock_out_after_incorrect_logins) {
         $mainFields->removeByName('FailedLoginCount');
     }
     $mainFields->removeByName('Salt');
     $mainFields->removeByName('NumVisit');
     $mainFields->removeByName('LastVisited');
     $fields->removeByName('Subscriptions');
     // Groups relation will get us into logical conflicts because
     // Members are displayed within  group edit form in SecurityAdmin
     $fields->removeByName('Groups');
     if (Permission::check('EDIT_PERMISSIONS')) {
         $groupsField = new TreeMultiselectField('Groups', false, 'Group');
         $fields->findOrMakeTab('Root.Groups', singleton('Group')->i18n_plural_name());
         $fields->addFieldToTab('Root.Groups', $groupsField);
         // Add permission field (readonly to avoid complicated group assignment logic).
         // This should only be available for existing records, as new records start
         // with no permissions until they have a group assignment anyway.
         if ($this->ID) {
             $permissionsField = new PermissionCheckboxSetField_Readonly('Permissions', singleton('Permission')->i18n_plural_name(), 'Permission', 'GroupID', $this->getManyManyComponents('Groups'));
             $fields->findOrMakeTab('Root.Permissions', singleton('Permission')->i18n_plural_name());
             $fields->addFieldToTab('Root.Permissions', $permissionsField);
         }
     }
     $defaultDateFormat = Zend_Locale_Format::getDateFormat($this->Locale);
     $dateFormatMap = array('MMM d, yyyy' => Zend_Date::now()->toString('MMM d, yyyy'), 'yyyy/MM/dd' => Zend_Date::now()->toString('yyyy/MM/dd'), 'MM/dd/yyyy' => Zend_Date::now()->toString('MM/dd/yyyy'), 'dd/MM/yyyy' => Zend_Date::now()->toString('dd/MM/yyyy'));
     $dateFormatMap[$defaultDateFormat] = Zend_Date::now()->toString($defaultDateFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
     $mainFields->push($dateFormatField = new Member_DatetimeOptionsetField('DateFormat', $this->fieldLabel('DateFormat'), $dateFormatMap));
     $dateFormatField->setValue($this->DateFormat);
     $defaultTimeFormat = Zend_Locale_Format::getTimeFormat($this->Locale);
     $timeFormatMap = array('h:mm a' => Zend_Date::now()->toString('h:mm a'), 'H:mm' => Zend_Date::now()->toString('H:mm'));
     $timeFormatMap[$defaultTimeFormat] = Zend_Date::now()->toString($defaultTimeFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
     $mainFields->push($timeFormatField = new Member_DatetimeOptionsetField('TimeFormat', $this->fieldLabel('TimeFormat'), $timeFormatMap));
     $timeFormatField->setValue($this->TimeFormat);
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
开发者ID:nicmart,项目名称:comperio-site,代码行数:64,代码来源:Member.php

示例3: _calculate


//.........这里部分代码省略.........
             $match[3] = self::getFullYear($match[3]);
             if ($calc == 'set' || $calc == 'cmp') {
                 --$months;
                 --$month;
                 --$match[1];
                 --$day;
                 $match[3] -= 1970;
                 $year -= 1970;
             }
             return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
             break;
         case self::RFC_1123:
             $result = preg_match('/^\\w{0,3},{0,1}\\s{0,1}(\\d{1,2})\\s(\\w{3})\\s(\\d{2,4})\\s(\\d{2}):(\\d{2}):{0,1}(\\d{0,2})\\s([+-]{1}\\d{4}|\\w{1,20})$/', $date, $match);
             if (!$result) {
                 require_once 'Zend/Date/Exception.php';
                 throw new Zend_Date_Exception("invalid date ({$date}) operand, RFC 1123 date format expected", 0, null, $date);
             }
             $months = $this->_getDigitFromName($match[2]);
             if ($calc == 'set' || $calc == 'cmp') {
                 --$months;
                 --$month;
                 --$match[1];
                 --$day;
                 $match[3] -= 1970;
                 $year -= 1970;
             }
             return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
             break;
         case self::RSS:
             $result = preg_match('/^\\w{3},\\s(\\d{2})\\s(\\w{3})\\s(\\d{2,4})\\s(\\d{1,2}):(\\d{2}):(\\d{2})\\s.{1,21}$/', $date, $match);
             if (!$result) {
                 require_once 'Zend/Date/Exception.php';
                 throw new Zend_Date_Exception("invalid date ({$date}) operand, RSS date format expected", 0, null, $date);
             }
             $months = $this->_getDigitFromName($match[2]);
             $match[3] = self::getFullYear($match[3]);
             if ($calc == 'set' || $calc == 'cmp') {
                 --$months;
                 --$month;
                 --$match[1];
                 --$day;
                 $match[3] -= 1970;
                 $year -= 1970;
             }
             return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
             break;
         case self::W3C:
             $result = preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})[+-]{1}\\d{2}:\\d{2}$/', $date, $match);
             if (!$result) {
                 require_once 'Zend/Date/Exception.php';
                 throw new Zend_Date_Exception("invalid date ({$date}) operand, W3C date format expected", 0, null, $date);
             }
             if ($calc == 'set' || $calc == 'cmp') {
                 --$match[2];
                 --$month;
                 --$match[3];
                 --$day;
                 $match[1] -= 1970;
                 $year -= 1970;
             }
             return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $match[2], 1 + $match[3], 1970 + $match[1], true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
             break;
         default:
             if (!is_numeric($date) || !empty($part)) {
                 try {
                     if (empty($part)) {
                         $part = Zend_Locale_Format::getDateFormat($locale) . " ";
                         $part .= Zend_Locale_Format::getTimeFormat($locale);
                     }
                     $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $part, 'locale' => $locale, 'fix_date' => true, 'format_type' => 'iso'));
                     if (strpos(strtoupper($part), 'YY') !== false and strpos(strtoupper($part), 'YYYY') === false) {
                         $parsed['year'] = self::getFullYear($parsed['year']);
                     }
                     if ($calc == 'set' || $calc == 'cmp') {
                         if (isset($parsed['month'])) {
                             --$parsed['month'];
                         } else {
                             $parsed['month'] = 0;
                         }
                         if (isset($parsed['day'])) {
                             --$parsed['day'];
                         } else {
                             $parsed['day'] = 0;
                         }
                         if (!isset($parsed['year'])) {
                             $parsed['year'] = 1970;
                         }
                     }
                     return $this->_assign($calc, $this->mktime(isset($parsed['hour']) ? $parsed['hour'] : 0, isset($parsed['minute']) ? $parsed['minute'] : 0, isset($parsed['second']) ? $parsed['second'] : 0, isset($parsed['month']) ? 1 + $parsed['month'] : 1, isset($parsed['day']) ? 1 + $parsed['day'] : 1, $parsed['year'], false), $this->getUnixTimestamp(), false);
                 } catch (Zend_Locale_Exception $e) {
                     if (!is_numeric($date)) {
                         require_once 'Zend/Date/Exception.php';
                         throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
                     }
                 }
             }
             return $this->_assign($calc, $date, $this->getUnixTimestamp(), false);
             break;
     }
 }
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:101,代码来源:Date.php

示例4: get_time_format

 /**
  * @return string ISO time format
  */
 public static function get_time_format()
 {
     require_once 'Zend/Date.php';
     return self::$time_format ? self::$time_format : Zend_Locale_Format::getTimeFormat(self::get_locale());
 }
开发者ID:normann,项目名称:sapphire,代码行数:8,代码来源:i18n.php

示例5: getCMSFields

 /**
  * Return a {@link FieldList} of fields that would appropriate for editing
  * this member.
  *
  * @return FieldList Return a FieldList of fields that would appropriate for
  *                   editing this member.
  */
 public function getCMSFields()
 {
     require_once 'Zend/Date.php';
     $self = $this;
     $this->beforeUpdateCMSFields(function ($fields) use($self) {
         $mainFields = $fields->fieldByName("Root")->fieldByName("Main")->Children;
         $password = new ConfirmedPasswordField('Password', null, null, null, true);
         $password->setCanBeEmpty(true);
         if (!$self->ID) {
             $password->showOnClick = false;
         }
         $mainFields->replaceField('Password', $password);
         $mainFields->replaceField('Locale', new DropdownField("Locale", _t('Member.INTERFACELANG', "Interface Language", 'Language of the CMS'), i18n::get_existing_translations()));
         $mainFields->removeByName('RememberLoginToken');
         $mainFields->removeByName('AutoLoginHash');
         $mainFields->removeByName('AutoLoginExpired');
         $mainFields->removeByName('PasswordEncryption');
         $mainFields->removeByName('PasswordExpiry');
         $mainFields->removeByName('LockedOutUntil');
         if (!$self->config()->lock_out_after_incorrect_logins) {
             $mainFields->removeByName('FailedLoginCount');
         }
         $mainFields->removeByName('Salt');
         $mainFields->removeByName('NumVisit');
         $mainFields->makeFieldReadonly('LastVisited');
         $fields->removeByName('Subscriptions');
         // Groups relation will get us into logical conflicts because
         // Members are displayed within  group edit form in SecurityAdmin
         $fields->removeByName('Groups');
         if (Permission::check('EDIT_PERMISSIONS')) {
             $groupsMap = array();
             foreach (Group::get() as $group) {
                 // Listboxfield values are escaped, use ASCII char instead of »
                 $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
             }
             asort($groupsMap);
             $fields->addFieldToTab('Root.Main', ListboxField::create('DirectGroups', singleton('Group')->i18n_plural_name())->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('Member.ADDGROUP', 'Add group', 'Placeholder text for a dropdown')));
             // Add permission field (readonly to avoid complicated group assignment logic).
             // This should only be available for existing records, as new records start
             // with no permissions until they have a group assignment anyway.
             if ($self->ID) {
                 $permissionsField = new PermissionCheckboxSetField_Readonly('Permissions', false, 'Permission', 'GroupID', $self->getManyManyComponents('Groups'));
                 $fields->findOrMakeTab('Root.Permissions', singleton('Permission')->i18n_plural_name());
                 $fields->addFieldToTab('Root.Permissions', $permissionsField);
             }
         }
         $permissionsTab = $fields->fieldByName("Root")->fieldByName('Permissions');
         if ($permissionsTab) {
             $permissionsTab->addExtraClass('readonly');
         }
         $defaultDateFormat = Zend_Locale_Format::getDateFormat(new Zend_Locale($self->Locale));
         $dateFormatMap = array('MMM d, yyyy' => Zend_Date::now()->toString('MMM d, yyyy'), 'yyyy/MM/dd' => Zend_Date::now()->toString('yyyy/MM/dd'), 'MM/dd/yyyy' => Zend_Date::now()->toString('MM/dd/yyyy'), 'dd/MM/yyyy' => Zend_Date::now()->toString('dd/MM/yyyy'));
         $dateFormatMap[$defaultDateFormat] = Zend_Date::now()->toString($defaultDateFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
         $mainFields->push($dateFormatField = new MemberDatetimeOptionsetField('DateFormat', $self->fieldLabel('DateFormat'), $dateFormatMap));
         $dateFormatField->setValue($self->DateFormat);
         $defaultTimeFormat = Zend_Locale_Format::getTimeFormat(new Zend_Locale($self->Locale));
         $timeFormatMap = array('h:mm a' => Zend_Date::now()->toString('h:mm a'), 'H:mm' => Zend_Date::now()->toString('H:mm'));
         $timeFormatMap[$defaultTimeFormat] = Zend_Date::now()->toString($defaultTimeFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
         $mainFields->push($timeFormatField = new MemberDatetimeOptionsetField('TimeFormat', $self->fieldLabel('TimeFormat'), $timeFormatMap));
         $timeFormatField->setValue($self->TimeFormat);
     });
     return parent::getCMSFields();
 }
开发者ID:hemant-chakka,项目名称:awss,代码行数:70,代码来源:Member.php

示例6: _calculate


//.........这里部分代码省略.........
             if (!$result) {
                 throw new Zend_Date_Exception("invalid date ({$date}) operand, RFC 1123 date format expected", $date);
             }
             $days = substr($match[0], 5, 2);
             $months = $this->getDigitFromName(substr($match[0], 8, 3));
             $years = substr($match[0], 12, 4);
             $hours = substr($match[0], 17, 2);
             $minutes = substr($match[0], 20, 2);
             $seconds = substr($match[0], 23, 2);
             if ($calc == 'set') {
                 --$months;
                 --$month;
                 --$days;
                 --$day;
                 $years -= 1970;
                 $year -= 1970;
             }
             return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1 + $months, 1 + $days, 1970 + $years, true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
             break;
         case Zend_Date::RSS:
             $result = preg_match('/^\\w{3},\\s\\d{2}\\s\\w{3}\\s\\d{4}\\s\\d{2}:\\d{2}:\\d{2}\\s[+-]{1}\\d{4}$/', $date, $match);
             if (!$result) {
                 throw new Zend_Date_Exception("invalid date ({$date}) operand, RSS date format expected", $date);
             }
             $days = substr($match[0], 5, 2);
             $months = $this->getDigitFromName(substr($match[0], 8, 3));
             $years = substr($match[0], 12, 4);
             $hours = substr($match[0], 17, 2);
             $minutes = substr($match[0], 20, 2);
             $seconds = substr($match[0], 23, 2);
             if ($calc == 'set') {
                 --$months;
                 --$month;
                 --$days;
                 --$day;
                 $years -= 1970;
                 $year -= 1970;
             }
             return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1 + $months, 1 + $days, 1970 + $years, true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
             break;
         case Zend_Date::W3C:
             $result = preg_match('/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[+-]{1}\\d{2}:\\d{2}$/', $date, $match);
             if (!$result) {
                 throw new Zend_Date_Exception("invalid date ({$date}) operand, W3C date format expected", $date);
             }
             $years = substr($match[0], 0, 4);
             $months = substr($match[0], 5, 2);
             $days = substr($match[0], 8, 2);
             $hours = substr($match[0], 11, 2);
             $minutes = substr($match[0], 14, 2);
             $seconds = substr($match[0], 17, 2);
             if ($calc == 'set') {
                 --$months;
                 --$month;
                 --$days;
                 --$day;
                 $years -= 1970;
                 $year -= 1970;
             }
             return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1 + $months, 1 + $days, 1970 + $years, true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
             break;
         default:
             if (!is_numeric($date) || !empty($part)) {
                 try {
                     if (self::$_Options['format_type'] == 'php') {
                         $part = Zend_Locale_Format::convertPhpToIsoFormat($part);
                     }
                     if (empty($part)) {
                         $part = Zend_Locale_Format::getDateFormat($locale) . " ";
                         $part .= Zend_Locale_Format::getTimeFormat($locale);
                     }
                     $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $part, 'locale' => $locale, 'fix_date' => true, 'format_type' => 'iso'));
                     if ($calc == 'set') {
                         if (isset($parsed['month'])) {
                             --$parsed['month'];
                         } else {
                             $parsed['month'] = 0;
                         }
                         if (isset($parsed['day'])) {
                             --$parsed['day'];
                         } else {
                             $parsed['day'] = 0;
                         }
                         if (isset($parsed['year'])) {
                             $parsed['year'] -= 1970;
                         } else {
                             $parsed['year'] = 0;
                         }
                     }
                     return $this->_assign($calc, $this->mktime(isset($parsed['hour']) ? $parsed['hour'] : 0, isset($parsed['minute']) ? $parsed['minute'] : 0, isset($parsed['second']) ? $parsed['second'] : 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], false), $this->getUnixTimestamp(), false);
                 } catch (Zend_Locale_Exception $e) {
                     if (!is_numeric($date)) {
                         throw new Zend_Date_Exception($e->getMessage(), $date);
                     }
                 }
             }
             return $this->_assign($calc, $date, $this->getUnixTimestamp(), false);
             break;
     }
 }
开发者ID:renatosoares,项目名称:blog-zend1,代码行数:101,代码来源:Date.php

示例7: install_locale

 /**
  * Installs the current locale into i18n
  *
  * @param boolean $persist Attempt to persist any detected locale within session / cookies
  */
 public static function install_locale($persist = true)
 {
     // Ensure the locale is set correctly given the designated parameters
     $locale = self::current_locale($persist);
     if (empty($locale)) {
         return;
     }
     i18n::set_locale($locale);
     // LC_NUMERIC causes SQL errors for some locales (comma as decimal indicator) so skip
     foreach (array(LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_TIME) as $category) {
         setlocale($category, "{$locale}.UTF-8", $locale);
     }
     // Get date/time formats from Zend
     require_once 'Zend/Date.php';
     i18n::config()->date_format = Zend_Locale_Format::getDateFormat($locale);
     i18n::config()->time_format = Zend_Locale_Format::getTimeFormat($locale);
 }
开发者ID:helpfulrobot,项目名称:tractorcow-silverstripe-fluent,代码行数:22,代码来源:Fluent.php

示例8: get


//.........这里部分代码省略.........
         // date strings
         case Zend_Date::ISO_8601:
             return $this->date('c', $this->getUnixTimestamp(), false);
             break;
         case Zend_Date::RFC_2822:
             return $this->date('r', $this->getUnixTimestamp(), false);
             break;
         case Zend_Date::TIMESTAMP:
             return $this->getUnixTimestamp();
             break;
             // additional formats
         // additional formats
         case Zend_Date::ERA:
             $year = $this->date('Y', $this->getUnixTimestamp(), false);
             if ($year < 0) {
                 $era = Zend_Locale_Data::getContent($locale, 'erashort', array('gregorian', '0'));
                 return $era['0'];
             }
             $era = Zend_Locale_Data::getContent($locale, 'erashort', array('gregorian', '1'));
             return $era['1'];
             break;
         case Zend_Date::ERA_NAME:
             $year = $this->date('Y', $this->getUnixTimestamp(), false);
             if ($year < 0) {
                 $era = Zend_Locale_Data::getContent($locale, 'era', array('gregorian', '0'));
                 return $era['0'];
             }
             $era = Zend_Locale_Data::getContent($locale, 'era', array('gregorian', '1'));
             if (!isset($era['1'])) {
                 return false;
             }
             return $era['1'];
             break;
         case Zend_Date::DATES:
             return $this->toString(Zend_Locale_Format::getDateFormat($locale), 'iso', $locale);
             break;
         case Zend_Date::DATE_FULL:
             $date = Zend_Locale_Data::getContent($locale, 'dateformat', array('gregorian', 'full'));
             return $this->toString($date['pattern'], 'iso', $locale);
             break;
         case Zend_Date::DATE_LONG:
             $date = Zend_Locale_Data::getContent($locale, 'dateformat', array('gregorian', 'long'));
             return $this->toString($date['pattern'], 'iso', $locale);
             break;
         case Zend_Date::DATE_MEDIUM:
             $date = Zend_Locale_Data::getContent($locale, 'dateformat', array('gregorian', 'medium'));
             return $this->toString($date['pattern'], 'iso', $locale);
             break;
         case Zend_Date::DATE_SHORT:
             $date = Zend_Locale_Data::getContent($locale, 'dateformat', array('gregorian', 'short'));
             return $this->toString($date['pattern'], 'iso', $locale);
             break;
         case Zend_Date::TIMES:
             return $this->toString(Zend_Locale_Format::getTimeFormat($locale), 'iso', $locale);
             break;
         case Zend_Date::TIME_FULL:
             $time = Zend_Locale_Data::getContent($locale, 'timeformat', array('gregorian', 'full'));
             return $this->toString($time['pattern'], 'iso', $locale);
             break;
         case Zend_Date::TIME_LONG:
             $time = Zend_Locale_Data::getContent($locale, 'timeformat', array('gregorian', 'long'));
             return $this->toString($time['pattern'], 'iso', $locale);
             break;
         case Zend_Date::TIME_MEDIUM:
             $time = Zend_Locale_Data::getContent($locale, 'timeformat', array('gregorian', 'medium'));
             return $this->toString($time['pattern'], 'iso', $locale);
             break;
         case Zend_Date::TIME_SHORT:
             $time = Zend_Locale_Data::getContent($locale, 'timeformat', array('gregorian', 'short'));
             return $this->toString($time['pattern'], 'iso', $locale);
             break;
         case Zend_Date::ATOM:
             return $this->date('Y\\-m\\-d\\TH\\:i\\:sP', $this->getUnixTimestamp(), false);
             break;
         case Zend_Date::COOKIE:
             return $this->date('l\\, d\\-M\\-y H\\:i\\:s e', $this->getUnixTimestamp(), false);
             break;
         case Zend_Date::RFC_822:
             return $this->date('D\\, d M y H\\:i\\:s O', $this->getUnixTimestamp(), false);
             break;
         case Zend_Date::RFC_850:
             return $this->date('l\\, d\\-M\\-y H\\:i\\:s e', $this->getUnixTimestamp(), false);
             break;
         case Zend_Date::RFC_1036:
             return $this->date('D\\, d M y H\\:i\\:s O', $this->getUnixTimestamp(), false);
             break;
         case Zend_Date::RFC_1123:
             return $this->date('D\\, d M Y H\\:i\\:s O', $this->getUnixTimestamp(), false);
             break;
         case Zend_Date::RFC_3339:
             return $this->date('Y\\-m\\-d\\TH\\:i\\:sP', $this->getUnixTimestamp(), false);
             break;
         case Zend_Date::RSS:
             return $this->date('D\\, d M Y H\\:i\\:s O', $this->getUnixTimestamp(), false);
             break;
         case Zend_Date::W3C:
             return $this->date('Y\\-m\\-d\\TH\\:i\\:sP', $this->getUnixTimestamp(), false);
             break;
     }
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:101,代码来源:Date.php

示例9: dateToStringInTzAndLocaleFormat

 /**
  * convert date to string
  * 
  * @param Tinebase_DateTime $date [optional]
  * @param string            $timezone [optional]
  * @param Zend_Locale       $locale [optional]
  * @param string            $part one of date, time or datetime [optional]
  * @param boolean           $addWeekday should the weekday be added (only works with $part = 'date[time]') [optional] 
  * @return string
  */
 public static function dateToStringInTzAndLocaleFormat(DateTime $date = null, $timezone = null, Zend_Locale $locale = null, $part = 'datetime', $addWeekday = false)
 {
     $date = $date !== null ? clone $date : Tinebase_DateTime::now();
     $timezone = $timezone !== null ? $timezone : Tinebase_Core::getUserTimezone();
     $locale = $locale !== null ? $locale : Tinebase_Core::get(Tinebase_Core::LOCALE);
     $date = new Zend_Date($date->getTimestamp());
     $date->setTimezone($timezone);
     if (in_array($part, array('date', 'time', 'datetime'))) {
         $dateString = $date->toString(Zend_Locale_Format::getDateFormat($locale), $locale);
         if ($addWeekday) {
             $dateString = $date->toString('EEEE', $locale) . ', ' . $dateString;
         }
         $timeString = $date->toString(Zend_Locale_Format::getTimeFormat($locale), $locale);
         switch ($part) {
             case 'date':
                 return $dateString;
             case 'time':
                 return $timeString;
             default:
                 return $dateString . ' ' . $timeString;
         }
     } else {
         return $date->toString($part, $locale);
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:35,代码来源:Translation.php

示例10: _normalize

 /**
  * Reads a localized value, normalizes and returns it.
  * Returns an empty string if no value is passed.
  * @param mixed $value
  * @param string $type (boolean|date|time|integer|float|decimal|currency)
  * @return mixed
  */
 private function _normalize($value, $type, $num_of_decimals)
 {
     if (strlen($value) == 0) {
         return '';
     }
     switch ($type) {
         case 'boolean':
             $yes_no = Zend_Locale_Data::getContent($this->_locale_engine, 'questionstrings');
             $yes_regexp = '/^(' . str_replace(':', '|', $yes_no['yes']) . ')$/i';
             if (preg_match($yes_regexp, $value)) {
                 return 1;
             }
             return 0;
         case 'date':
             $date = Zend_Locale_Format::getDate($value, array('locale' => $this->_locale_engine, 'fix_date' => true));
             $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
             $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
             return "{$date['year']}-{$date['month']}-{$date['day']}";
         case 'time':
             $date_format = Zend_Locale_Format::getTimeFormat($this->_locale_engine);
             $date = Zend_Locale_Format::getDate($value, array('date_format' => $date_format, 'locale' => $this->_locale_engine));
             if (!isset($date['hour'])) {
                 $date['hour'] = '00';
             }
             if (!isset($date['minute'])) {
                 $date['minute'] = '00';
             }
             if (!isset($date['second'])) {
                 $date['second'] = '00';
             }
             return "{$date['hour']}:{$date['minute']}:{$date['second']}";
         case 'datetime':
             $date = Zend_Locale_Format::getDateTime($value, array('locale' => $this->_locale_engine, 'fix_date' => true));
             $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
             $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
             $date['hour'] = str_pad($date['hour'], 2, 0, STR_PAD_LEFT);
             $date['minute'] = str_pad($date['minute'], 2, 0, STR_PAD_LEFT);
             $date['second'] = str_pad($date['second'], 2, 0, STR_PAD_LEFT);
             return "{$date['year']}-{$date['month']}-{$date['day']} {$date['hour']}:{$date['minute']}:{$date['second']}";
             break;
         case 'integer':
             return Zend_Locale_Format::getInteger($value, array('locale' => $this->_locale_engine));
         case 'float':
             if ($num_of_decimals === null) {
                 $num_of_decimals = 3;
             }
             return Zend_Locale_Format::getFloat($value, array('precision' => $num_of_decimals, 'locale' => $this->_locale_engine));
         case 'decimal':
             if ($num_of_decimals === null) {
                 $num_of_decimals = 2;
             }
             return Zend_Locale_Format::getFloat($value, array('precision' => $num_of_decimals, 'locale' => $this->_locale_engine));
     }
     return $value;
 }
开发者ID:eliudiaz,项目名称:p4a,代码行数:62,代码来源:p4a_i18n.php

示例11: get_time_format

 /**
  * @return string ISO time format
  */
 public static function get_time_format()
 {
     require_once 'Zend/Date.php';
     $timeFormat = Config::inst()->get('i18n', 'time_format');
     return $timeFormat ? $timeFormat : Zend_Locale_Format::getTimeFormat(self::get_locale());
 }
开发者ID:jareddreyer,项目名称:catalogue,代码行数:9,代码来源:i18n.php


注:本文中的Zend_Locale_Format::getTimeFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。