本文整理汇总了PHP中Zend_Date::setOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::setOptions方法的具体用法?PHP Zend_Date::setOptions怎么用?PHP Zend_Date::setOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::setOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
* @param array $options
* @param string $date
*/
public function __construct(array $options = array(), $date = null)
{
parent::__construct($date);
$this->_request = Zend_Controller_Front::getInstance()->getRequest();
$this->setDate($date, "M yy");
$this->setOptions($options);
// Caching
$cache = null;
if (array_key_exists('autoCache', $options)) {
if (extension_loaded('apc')) {
$cache = Zend_Cache::factory('Core', 'apc');
}
} else {
if (array_key_exists('cache', $options)) {
$cache = $options['cache'];
} else {
if (Zend_Registry::isRegistered('SZend_Calendar_Cache')) {
$cache = Zend_Registry::get('SZend_Calendar_Cache');
}
}
}
if (null !== $cache) {
if (!$cache instanceof Zend_Cache_Core) {
throw new Zend_Exception('Instance of Zend_Cache expected');
}
$this->_date->setOptions(array('cache' => $cache));
}
$this->_generateWeeks();
#$this->_weeks = $this->getCalendarMonthDayDataArray();
$this->init();
}
示例2: init
/**
* To init the view
*
* @return Zend_View $view
*/
public function init()
{
$frontendOptions = array('automatic_serialization' => true, 'lifetime' => 86400);
$backendOptions = array('cache_dir' => PROJECT_ROOT . '/repository/cache/');
if ('development' == APPLICATION_ENV) {
$frontendOptions['caching'] = false;
//关闭缓存
} else {
$classFileIncCache = $backendOptions['cache_dir'] . 'pluginLoaderCache.php';
if (file_exists($classFileIncCache)) {
include_once $classFileIncCache;
}
Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
}
$this->_cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_cache);
//缓存Zend_Db_Table元数据
Zend_Date::setOptions(array('cache' => $this->_cache));
//缓存Zend_Date
Zend_Translate::setCache($this->_cache);
//缓存Zend_Translate
Zend_Registry::set('cache', $this->_cache);
// Return it, so that it can be stored by the bootstrap
return $this->_cache;
}
示例3: _initTranslation
protected function _initTranslation()
{
$cache = $this->_getCache('core');
Zend_Translate::setCache($cache);
Zend_Date::setOptions(array('cache' => $cache));
Zend_Paginator::setCache($cache);
}
示例4: __construct
/**
* Constructor
* @param array $options
*/
public function __construct(array $options = array())
{
$this->_request = Zend_Controller_Front::getInstance()->getRequest();
// Generate calendar timestamp
if (array_key_exists('timestamp', $options)) {
$timestamp = $options['timestamp'];
} else {
// Default date based on current
$date = array('hour' => (int) date('h'), 'minute' => (int) date('i'), 'second' => (int) date('s'), 'month' => (int) date('m'), 'day' => (int) date('d'), 'year' => (int) date('Y'));
// Timestamp from parameters
if ($this->_request->getParam('second')) {
$date['second'] = $this->_request->getParam('second');
}
if ($this->_request->getParam('minute')) {
$date['minute'] = $this->_request->getParam('minute');
}
if ($this->_request->getParam('hour')) {
$date['hour'] = $this->_request->getParam('hour');
}
if ($this->_request->getParam('day')) {
$date['day'] = $this->_request->getParam('day');
}
if ($this->_request->getParam('month')) {
$date['month'] = $this->_request->getParam('month');
}
if ($this->_request->getParam('year')) {
$date['year'] = $this->_request->getParam('year');
}
// Finally merge with any date options
$date = array_merge($date, array_key_exists('date', $options) ? $options['date'] : array());
// Generate the timestamp
$timestamp = mktime($date['hour'], $date['minute'], $date['second'], $date['month'], $date['day'], $date['year']);
}
$this->setDate($timestamp);
$this->setOptions($options);
// Caching
$cache = null;
if (array_key_exists('autoCache', $options)) {
if (extension_loaded('apc')) {
$cache = Zend_Cache::factory('Core', 'apc');
}
} else {
if (array_key_exists('cache', $options)) {
$cache = $options['cache'];
} else {
if (Zend_Registry::isRegistered('SZend_Calendar_Cache')) {
$cache = Zend_Registry::get('SZend_Calendar_Cache');
}
}
}
if (null !== $cache) {
if (!$cache instanceof Zend_Cache_Core) {
throw new Zend_Exception('Instance of Zend_Cache expected');
}
$this->_date->setOptions(array('cache' => $cache));
}
$this->_generateWeeks();
$this->init();
}
示例5: viewCheckChuNhatThuBay
public function viewCheckChuNhatThuBay($day = 0, $month = 0, $year = 0)
{
Zend_Date::setOptions(array('format_type' => 'php'));
$date = new Zend_Date($day . '/' . $month . '/' . $year, 'd/m/Y');
if ($date->toString('D') == 'CN' || $date->toString('D') == 'Th 7') {
return 'class="error"';
}
}
示例6: _initCacheDir
/**
*
*/
protected function _initCacheDir()
{
$frontendOptions = array('lifetime' => 86400, 'automatic_serialization' => true, 'automatic_cleaning_factor' => 1);
$backendOptions = array('cache_dir' => APPLICATION_PATH . '/cache');
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
Zend_Date::setOptions(array('cache' => $cache));
}
示例7: renderDate
/**
* defaults to current date
* we use php's formating here
*/
public function renderDate($timestamp = null, $format = 'F j, Y')
{
if ($timestamp == null) {
$timestamp = time();
}
Zend_Date::setOptions(array('format_type' => 'php'));
$date = new Zend_Date($timestamp);
return $date->toString($format);
}
示例8: setSubscription
/**
* Presets flat data from subscription
* @param AW_Sarp_Model_Subscription $Subscription
* @return AW_Sarp_Model_Subscription_Flat
*/
public function setSubscription(AW_Sarp_Model_Subscription $Subscription)
{
Zend_Date::setOptions(array('extend_month' => true));
// Fix Zend_Date::addMonth unexpected result
if (!$Subscription->isInfinite()) {
$expireDate = $Subscription->getDateExpire()->toString(AW_Sarp_Model_Subscription::DB_DATE_FORMAT);
} else {
$expireDate = null;
}
if ($Subscription->getIsNew()) {
$lastOrderAmount = $Subscription->getQuote()->getGrandTotal();
$virtual = $Subscription->getQuote()->getIsVirtual();
} else {
$lastOrderAmount = $Subscription->getLastOrder()->getGrandTotal();
$virtual = $Subscription->getLastOrder()->getIsVirtual();
}
if ($Subscription->isActive()) {
$paymentOffset = $Subscription->getPeriod()->getPaymentOffset();
// Get next payment date
if (!$Subscription->getLastPaidDate()) {
$nextPaymentDate = $Subscription->getLastOrder()->getCreatedAtStoreDate();
$nextPaymentDate = $Subscription->getNextSubscriptionEventDate($Subscription->getDateStart());
$nextDeliveryDate = clone $Subscription->getDateStart();
$nextDeliveryDate->addDayOfYear(0 + floatval($paymentOffset));
} else {
$nextPaymentDate = $Subscription->getNextSubscriptionEventDate();
}
if ($paymentOffset) {
if (!$Subscription->getLastPaidDate()) {
// No payments made yet
$lastOrderDate = clone $Subscription->getDateStart();
$lastOrderDate->addDayOfYear(0 - floatval($paymentOffset));
} else {
$lastOrderDate = $Subscription->getLastOrder()->getCreatedAtStoreDate();
}
$probablyDeliveryDate = clone $lastOrderDate;
$probablyDeliveryDate = $probablyDeliveryDate->addDayOfYear(floatval($paymentOffset));
if ($probablyDeliveryDate->compare(new Zend_Date(), Zend_Date::DATE_SHORT) > 0) {
$nextDeliveryDate = clone $lastOrderDate;
}
$nextPaymentDate->addDayOfYear(0 - floatval($paymentOffset));
}
if (!isset($nextDeliveryDate)) {
$nextDeliveryDate = clone $nextPaymentDate;
}
$nextDeliveryDate = $nextDeliveryDate->addDayOfYear(floatval($paymentOffset))->toString(AW_Sarp_Model_Subscription::DB_DATE_FORMAT);
$nextPaymentDate = $nextPaymentDate->toString(AW_Sarp_Model_Subscription::DB_DATE_FORMAT);
} else {
// Drop next payment date if subscription is suspended
$nextDeliveryDate = $nextPaymentDate = null;
}
$this->setSubscriptionId($Subscription->getId())->setCustomerName($Subscription->getCustomer()->getName())->setCustomerEmail($Subscription->getCustomer()->getEmail())->setFlatLastOrderStatus($Subscription->getLastOrder()->getStatus())->setFlatLastOrderAmount($lastOrderAmount)->setFlatLastOrderCurrencyCode($Subscription->getLastOrder()->getOrderCurrencyCode())->setFlatDateExpire($expireDate)->setHasShipping(1 - $virtual)->setFlatNextPaymentDate($nextPaymentDate)->setFlatNextDeliveryDate($nextDeliveryDate)->setProductsText($this->_convertProductsText($Subscription))->setProductsSku($this->_convertProductsSku($Subscription));
$Subscription->setCustomerName($Subscription->getCustomer()->getName())->setCustomerEmail($Subscription->getCustomer()->getEmail())->setFlatLastOrderStatus($Subscription->getLastOrder()->getStatus())->setFlatLastOrderAmount($lastOrderAmount)->setFlatLastOrderCurrencyCode($Subscription->getLastOrder()->getOrderCurrencyCode())->setFlatDateExpire($expireDate)->setHasShipping(1 - $virtual)->setFlatNextPaymentDate($nextPaymentDate)->setFlatNextDeliveryDate($nextDeliveryDate)->setProductsText($this->_convertProductsText($Subscription))->setProductsSku($this->_convertProductsSku($Subscription));
return $this;
}
示例9: format
public function format($format = 'Y-m-d', $language = null)
{
$needsZendDate = !!array_intersect(array('D', 'l', 'S', 'F', 'M', 'e'), str_split($format));
if (!$needsZendDate) {
return date($format, $this->_timestamp);
} else {
$date = new Zend_Date($this->_timestamp, Zend_Date::TIMESTAMP);
$date->setOptions(array('format_type' => 'php'));
$date->setLocale($language);
return $date->toString($format);
}
}
示例10: __construct
public function __construct()
{
Loader::library('3rdparty/Zend/Date');
Loader::library('3rdparty/Zend/Translate');
$this->setLocale(defined('ACTIVE_LOCALE') ? ACTIVE_LOCALE : 'en_US');
Zend_Date::setOptions(array('format_type' => 'php'));
$cache = Cache::getLibrary();
if (is_object($cache)) {
Zend_Translate::setCache($cache);
Zend_Date::setOptions(array('cache' => $cache));
}
}
示例11: datePicker
/**
* this helper renders a date picker (requires jquery date)
*
* @param string $name
* @param timestamp $value
*
*/
public function datePicker($name, $value = null)
{
//format the timestamp
if ($value > 0) {
Zend_Date::setOptions(array('format_type' => 'php'));
$date = new Zend_Date($value);
$value = $date->toString('m-d-Y');
} else {
//we dont want any value that is not a valid date
$value = null;
}
return $this->view->formText($name, $value, array('class' => 'date-picker'));
}
示例12: _initAppCache
/**
* Setup our cache
*/
protected function _initAppCache()
{
$this->bootstrap('cachemanager');
$metaCache = $this->getResource('cachemanager')->getCache('metadata');
$dateCache = $this->getResource('cachemanager')->getCache('date');
Zend_Db_Table_Abstract::setDefaultMetadataCache($metaCache);
Zend_Date::setOptions(array('cache' => $dateCache));
if ('production' === $this->getEnvironment()) {
$classFileIncCache = APPLICATION_PATH . '/tmp/pluginLoaderCache.php';
if (file_exists($classFileIncCache)) {
include_once $classFileIncCache;
}
Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
}
}
示例13: Nice
public function Nice($format = false)
{
if ($this->value) {
if ($format === false) {
if (self::$format_nice !== false) {
$format = self::$format_nice;
} else {
$format = _t('ZENDDATE.DATETIMEFORMATNICE', 'd/m/Y H:i a');
}
}
Zend_Date::setOptions(array('format_type' => 'php'));
$ZD = new Zend_Date($this->value, i18n::get_locale());
return $ZD->toString($format);
}
}
示例14: processOldLogs
public function processOldLogs()
{
$Date = new Zend_Date();
Zend_Date::setOptions(array('extend_month' => true));
$Date->sub(Mage::getStoreConfig(self::XML_PATH_LOGGER_STORE_DAYS), Zend_Date::DAY);
$collection = $this->getCollection()->addOlderThanFilter($Date);
if (Mage::getStoreConfig(self::XML_PATH_ENABLE_ARCHIVATION)) {
$resourceSingleton = Mage::getResourceSingleton('aw_lib/logger');
$sql = $resourceSingleton->getPartInsertSql('aw_lib_logger', $collection->getSelect());
$resourceSingleton->createBackupFile($sql);
}
foreach ($collection as $entry) {
$entry->delete();
}
return $this;
}
示例15: _setCache
/**
* Inizializza la cache per rendere più veloci le operazioni sulle date.
*
* @throws Zend_Exception
*/
protected function _setCache()
{
$cache = null;
if (isset($this->_options['autoCache']) && extension_loaded('apc')) {
$cache = Zend_Cache::factory('Core', 'apc');
} elseif (isset($this->_options['cache'])) {
$cache = $this->_options['cache'];
} elseif (Zend_Registry::isRegistered('Zwe_Calendar_Cache')) {
$cache = Zend_Registry::get('Zwe_Calendar_Cache');
}
if (isset($cache)) {
if (!$cache instanceof Zend_Cache_Core) {
throw new Zend_Exception('Instance of Zend_Cache_Core expected');
}
$this->_date->setOptions(array('cache' => $cache));
}
}