本文整理汇总了PHP中Zend_Date::toValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date::toValue方法的具体用法?PHP Zend_Date::toValue怎么用?PHP Zend_Date::toValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Date
的用法示例。
在下文中一共展示了Zend_Date::toValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateFeed
/**
* Add feed to system
*
* @param Feed $feed
*/
private function updateFeed(Feed $feed)
{
require_once 'Ifphp/models/Posts.php';
$feedSource = Zend_Feed_Reader::import($feed->url);
$posts = new Posts();
$tdate = $feedSource->current()->getDateModified();
$tdate = new Zend_Date($tdate);
while ($feedSource->valid() && $tdate->toValue() > $feed->lastPing && !$posts->getByLink($feedSource->current()->getPermaLink())) {
$tdate = $feedSource->current()->getDateModified();
$tdate = new Zend_Date($tdate);
$defaultFilterChain = new Zend_Filter();
$defaultFilterChain->addFilter(new Ifphp_Filter_XSSClean());
$defaultFilterChain->addFilter(new Zend_Filter_StringTrim());
$defaultFilterChain->addFilter(new Zend_Filter_StripTags());
$post = $posts->createRow();
$post->title = $defaultFilterChain->filter($feedSource->current()->getTitle());
$post->description = $defaultFilterChain->filter($feedSource->current()->getDescription());
$post->feedId = $defaultFilterChain->filter($feed->id);
$post->link = $defaultFilterChain->filter($feedSource->current()->getPermaLink());
$post->publishDate = $tdate->toValue();
$post->save();
Ifphp_Controller_Front::getInstance()->getPluginBroker()->addPost($post, $feed);
$feedSource->next();
}
$feed->lastPing = time();
$feed->save();
}
示例2: getLastMonths
public function getLastMonths()
{
$currentDate = new Zend_Date(date("Y-m-d", Mage::getModel('core/date')->timestamp(time())));
$currentMonth = $currentDate->toValue(Zend_Date::MONTH_SHORT);
$currentYear = $currentDate->toValue(Zend_Date::YEAR);
$lastMonths = array();
for ($i = 0; $i < self::LAST_MONTHS_COUNT; $i++) {
$number = $currentMonth - $i;
$year = $currentYear;
if ($number <= 0) {
$year -= 1;
$number += 12;
}
$lastMonths[$number] = $this->getMonthName($number, $year);
}
return $lastMonths;
}
示例3: render
public function render(Varien_Object $row)
{
$html = '';
$weekendsexclude = Mage::getStoreConfig('reminder/timesettings/weekendsexclude');
// Obtain the order/reminder details
$incrementid = $row->getIncrementId();
$reminderorders = Mage::getModel('reminder/reminder')->getCollection()->addFieldToFilter('increment_id', $incrementid)->getItems();
$reminderorder = reset($reminderorders);
// Obtain the age
$now = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
$orderdate = new Zend_Date($row->getCreatedAt(), 'yyyy-MM-dd');
$age = $now->sub($orderdate)->toValue();
$days = ceil($age / 60 / 60 / 24);
// Obtain the age (weekend excluded)
if ($weekendsexclude == 'enabled') {
$start_date = new Zend_Date($row->getCreatedAt(), 'yyyy-MM-dd');
$end_date = new Zend_Date($start_date);
$dayscounter = $days;
$weekenddays = 0;
while ($dayscounter > 0) {
$weekdaydigit = $end_date->toValue(Zend_Date::WEEKDAY_DIGIT);
if ($weekdaydigit == 0 || $weekdaydigit == 6) {
$weekenddays++;
}
$end_date->addDay(1);
$dayscounter--;
}
$days = $days - $weekenddays;
}
// Display the HTML
$html .= $reminderorder->getReminders();
$html .= ' (age: ' . $days . ')';
$html .= '<br/><a href="' . $this->getUrl('*/*/manipulate/option/add/id/' . $row->getIncrementId()) . '">' . Mage::helper('reminder')->__('add') . ' 1</a>';
$html .= '<br/><a href="' . $this->getUrl('*/*/manipulate/option/sub/id/' . $row->getIncrementId()) . '">' . Mage::helper('reminder')->__('remove') . ' 1</a>';
$html .= '<br/><a href="' . $this->getUrl('*/*/manipulate/option/reset/id/' . $row->getIncrementId()) . '">' . Mage::helper('reminder')->__('reset to') . ' 0</a>';
return $html;
}
示例4: testToValue
/**
* Test for toValue
*/
public function testToValue()
{
$locale = new Zend_Locale('de_AT');
$date = new Zend_Date(1234567890, null, $locale);
$date->setTimezone(date_default_timezone_get());
$this->assertSame(1234567890, $date->toValue());
$this->assertSame(14, $date->toValue(Zend_Date::DAY));
$date->setTimezone('UTC');
$this->assertSame(13, $date->toValue(Zend_Date::DAY));
$this->assertFalse($date->toValue(Zend_Date::WEEKDAY_SHORT));
$this->assertSame(13, $date->toValue(Zend_Date::DAY_SHORT));
$this->assertFalse($date->toValue(Zend_Date::WEEKDAY));
$this->assertSame(5, $date->toValue(Zend_Date::WEEKDAY_8601));
$this->assertFalse($date->toValue(Zend_Date::DAY_SUFFIX));
$this->assertSame(5, $date->toValue(Zend_Date::WEEKDAY_DIGIT));
$this->assertSame(43, $date->toValue(Zend_Date::DAY_OF_YEAR));
$this->assertFalse($date->toValue(Zend_Date::WEEKDAY_NARROW));
$this->assertFalse($date->toValue(Zend_Date::WEEKDAY_NAME));
$this->assertSame(7, $date->toValue(Zend_Date::WEEK));
$this->assertFalse($date->toValue(Zend_Date::MONTH_NAME));
$this->assertSame(2, $date->toValue(Zend_Date::MONTH));
$this->assertFalse($date->toValue(Zend_Date::MONTH_NAME_SHORT));
$this->assertSame(2, $date->toValue(Zend_Date::MONTH_SHORT));
$this->assertSame(28, $date->toValue(Zend_Date::MONTH_DAYS));
$this->assertFalse($date->toValue(Zend_Date::MONTH_NAME_NARROW));
$this->assertSame(0, $date->toValue(Zend_Date::LEAPYEAR));
$this->assertSame(2009, $date->toValue(Zend_Date::YEAR_8601));
$this->assertSame(2009, $date->toValue(Zend_Date::YEAR));
$this->assertSame(9, $date->toValue(Zend_Date::YEAR_SHORT));
$this->assertSame(9, $date->toValue(Zend_Date::YEAR_SHORT_8601));
$this->assertFalse($date->toValue(Zend_Date::MERIDIEM));
$this->assertSame(21, $date->toValue(Zend_Date::SWATCH));
$this->assertSame(11, $date->toValue(Zend_Date::HOUR_SHORT_AM));
$this->assertSame(23, $date->toValue(Zend_Date::HOUR_SHORT));
$this->assertSame(11, $date->toValue(Zend_Date::HOUR_AM));
$this->assertSame(23, $date->toValue(Zend_Date::HOUR));
$this->assertSame(31, $date->toValue(Zend_Date::MINUTE));
$this->assertSame(30, $date->toValue(Zend_Date::SECOND));
$this->assertSame(0, $date->toValue(Zend_Date::MILLISECOND));
$this->assertSame(31, $date->toValue(Zend_Date::MINUTE_SHORT));
$this->assertSame(30, $date->toValue(Zend_Date::SECOND_SHORT));
$this->assertFalse($date->toValue(Zend_Date::TIMEZONE_NAME));
$this->assertSame(0, $date->toValue(Zend_Date::DAYLIGHT));
$this->assertSame(0, $date->toValue(Zend_Date::GMT_DIFF));
$this->assertFalse($date->toValue(Zend_Date::GMT_DIFF_SEP));
$this->assertFalse($date->toValue(Zend_Date::TIMEZONE));
$this->assertSame(0, $date->toValue(Zend_Date::TIMEZONE_SECS));
$this->assertFalse($date->toValue(Zend_Date::ISO_8601));
$this->assertFalse($date->toValue(Zend_Date::RFC_2822));
$this->assertSame(1234567890, $date->toValue(Zend_Date::TIMESTAMP));
$this->assertFalse($date->toValue(Zend_Date::ERA));
$this->assertFalse($date->toValue(Zend_Date::ERA_NAME));
$this->assertFalse($date->toValue(Zend_Date::DATES));
$this->assertFalse($date->toValue(Zend_Date::DATE_FULL));
$this->assertFalse($date->toValue(Zend_Date::DATE_LONG));
$this->assertFalse($date->toValue(Zend_Date::DATE_MEDIUM));
$this->assertFalse($date->toValue(Zend_Date::DATE_SHORT));
$this->assertFalse($date->toValue(Zend_Date::TIMES));
$this->assertFalse($date->toValue(Zend_Date::TIME_FULL));
$this->assertFalse($date->toValue(Zend_Date::TIME_LONG));
$this->assertFalse($date->toValue(Zend_Date::TIME_MEDIUM));
$this->assertFalse($date->toValue(Zend_Date::TIME_SHORT));
$this->assertFalse($date->toValue(Zend_Date::DATETIME));
$this->assertFalse($date->toValue(Zend_Date::DATETIME_FULL));
$this->assertFalse($date->toValue(Zend_Date::DATETIME_LONG));
$this->assertFalse($date->toValue(Zend_Date::DATETIME_MEDIUM));
$this->assertFalse($date->toValue(Zend_Date::DATETIME_SHORT));
$this->assertFalse($date->toValue(Zend_Date::ATOM));
$this->assertFalse($date->toValue(Zend_Date::COOKIE));
$this->assertFalse($date->toValue(Zend_Date::RFC_822));
$this->assertFalse($date->toValue(Zend_Date::RFC_850));
$this->assertFalse($date->toValue(Zend_Date::RFC_1036));
$this->assertFalse($date->toValue(Zend_Date::RFC_1123));
$this->assertFalse($date->toValue(Zend_Date::RFC_3339));
$this->assertFalse($date->toValue(Zend_Date::RSS));
$this->assertFalse($date->toValue(Zend_Date::W3C));
$date->setTimezone('Indian/Maldives');
$this->assertFalse($date->toValue(Zend_Date::WEEKDAY_SHORT));
$this->assertSame(14, $date->toValue(Zend_Date::DAY_SHORT));
$this->assertFalse($date->toValue(Zend_Date::WEEKDAY));
$this->assertSame(6, $date->toValue(Zend_Date::WEEKDAY_8601));
$this->assertFalse($date->toValue(Zend_Date::DAY_SUFFIX));
$this->assertSame(6, $date->toValue(Zend_Date::WEEKDAY_DIGIT));
$this->assertSame(44, $date->toValue(Zend_Date::DAY_OF_YEAR));
$this->assertFalse($date->toValue(Zend_Date::WEEKDAY_NARROW));
$this->assertFalse($date->toValue(Zend_Date::WEEKDAY_NAME));
$this->assertSame(7, $date->toValue(Zend_Date::WEEK));
$this->assertFalse($date->toValue(Zend_Date::MONTH_NAME));
$this->assertSame(2, $date->toValue(Zend_Date::MONTH));
$this->assertFalse($date->toValue(Zend_Date::MONTH_NAME_SHORT));
$this->assertSame(2, $date->toValue(Zend_Date::MONTH_SHORT));
$this->assertSame(28, $date->toValue(Zend_Date::MONTH_DAYS));
$this->assertFalse($date->toValue(Zend_Date::MONTH_NAME_NARROW));
$this->assertSame(0, $date->toValue(Zend_Date::LEAPYEAR));
$this->assertSame(2009, $date->toValue(Zend_Date::YEAR_8601));
$this->assertSame(2009, $date->toValue(Zend_Date::YEAR));
$this->assertSame(9, $date->toValue(Zend_Date::YEAR_SHORT));
//.........这里部分代码省略.........
示例5: testToValue
/**
* Test for toValue
*/
public function testToValue()
{
$locale = new Zend_Locale('de_AT');
$date = new Zend_Date(1234567890, null, $locale);
$date->setTimezone(date_default_timezone_get());
$this->assertSame($date->toValue(), 1234567890);
$this->assertSame($date->toValue(Zend_Date::DAY), 14);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::DAY), 13);
$date->setTimezone('Indian/Maldives');
//Friday, 13-Feb-09 23:31:30 UTC
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_SHORT), false);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_SHORT), false);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::DAY_SHORT), 14);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::DAY_SHORT), 13);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::WEEKDAY), false);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::WEEKDAY), false);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_8601), 6);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_8601), 5);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::DAY_SUFFIX), false);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::DAY_SUFFIX), false);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_DIGIT), 6);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_DIGIT), 5);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::DAY_OF_YEAR), 44);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::DAY_OF_YEAR), 43);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_NARROW), false);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_NARROW), false);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_NAME), false);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_NAME), false);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::WEEK), 7);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::WEEK), 7);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::MONTH_NAME), false);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::MONTH_NAME), false);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::MONTH), 2);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::MONTH), 2);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::MONTH_NAME_SHORT), false);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::MONTH_NAME_SHORT), false);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::MONTH_SHORT), 2);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::MONTH_SHORT), 2);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::MONTH_DAYS), 28);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::MONTH_DAYS), 28);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::MONTH_NAME_NARROW), false);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::MONTH_NAME_NARROW), false);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::LEAPYEAR), 0);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::LEAPYEAR), 0);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::YEAR_8601), 2009);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::YEAR_8601), 2009);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::YEAR), 2009);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::YEAR), 2009);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::YEAR_SHORT), 9);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::YEAR_SHORT), 9);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::YEAR_SHORT_8601), 9);
$date->setTimezone('UTC');
$this->assertSame($date->toValue(Zend_Date::YEAR_SHORT_8601), 9);
$date->setTimezone('Indian/Maldives');
$this->assertSame($date->toValue(Zend_Date::MERIDIEM), false);
$date->setTimezone('UTC');
//.........这里部分代码省略.........
示例6: getRandomRecipientForCampaign
//.........这里部分代码省略.........
//var_dump($send_to_those_mailing_lists);
//exit;
shuffle($send_to_those_mailing_lists);
foreach ($send_to_those_mailing_lists as $i) {
$data = array();
$data['group_id'] = $i;
$data['is_active'] = 1;
$data = $this->getJobfeeds($data);
//var_dump($data);
if (!empty($data)) {
foreach ($data as $i2) {
$ids[] = $i2['id'];
}
}
}
$send_to_those_mailing_lists = $ids;
shuffle($send_to_those_mailing_lists);
}
//var_dump($send_to_those_mailing_lists);
//exit;
if (!empty($send_to_those_mailing_lists)) {
$mailing_list_groups_query = ' feed_id=0 ';
foreach ($send_to_those_mailing_lists as $item) {
$mailing_list_groups_query = $mailing_list_groups_query . " or feed_id={$item} ";
}
$mailing_list_groups_query = " ({$mailing_list_groups_query}) and ";
} else {
return false;
}
//exit($mailing_list_groups_query);
$date = new Zend_Date();
$date->sub('24', Zend_Date::HOUR);
//?
$past = $date->toValue();
$past = date("Y-m-d H:i:s", $past);
$now = date("Y-m-d H:i:s");
$q = " SELECT mail_id FROM {$table} where mailsent_date > '{$campaign_info['campaign_start_date']}' and mailsent_date < '{$campaign_info['campaign_end_date']}' and campaign_id={$campaign_info['id']} ";
$query = CI::db()->query($q);
$query = $query->result_array();
$mail_ids_to_exclude = array();
$mails_to_exclude = array();
if (!empty($query)) {
foreach ($query as $item) {
if (intval($item['mail_id']) != 0) {
$mail_ids_to_exclude[] = intval($item['mail_id']);
$table2 = TABLE_PREFIX . 'cacaomail_mails_to_send';
$q = " SELECT job_email FROM {$table2} where id={$item['mail_id']} limit 1 ";
$q = CI::db()->query($q);
$q = $q->row_array();
$mails_to_exclude[] = $q['job_email'];
}
}
$mails_to_exclude = array_unique($mails_to_exclude);
$mail_ids_to_exclude = array_unique($mail_ids_to_exclude);
}
//var_dump($mail_ids_to_exclude);
if (!empty($mail_ids_to_exclude)) {
$exclude_q = ' id!=0 ';
$exclude_mails_q = ' job_email is not null ';
foreach ($mail_ids_to_exclude as $i) {
$exclude_q = $exclude_q . " AND id<>{$i} ";
}
foreach ($mails_to_exclude as $i) {
$exclude_mails_q = $exclude_mails_q . " AND job_email not like '{$i}' ";
}
//print $exclude_q;
示例7: _updateUserDb
private function _updateUserDb()
{
$fb_users = HTS_Util::getDbTable('users');
$fb_user = $fb_users->findOneByIdSocial($this->_id_social);
if (empty($fb_user)) {
$user_profile = $this->_social->api('/me');
if (FB_DEBUG) {
Zend_Debug::dump($user_profile);
}
$fb_user = HTS_Util::getDbRow('users');
$birthday = new Zend_Date(@$user_profile['Birthday'], 'dd/MM/yyyy');
$updated_time = new Zend_Date(@$user_profile['Updated_time']);
//TODO some values are null -> undefined index warning
$fb_user->id_social = $user_profile['Id'];
$fb_user->name = $user_profile['Name'];
$fb_user->first_name = @$user_profile['First_name'];
$fb_user->middle_name = @$user_profile['Middle_name'];
$fb_user->last_name = @$user_profile['Last_name'];
$fb_user->link = $user_profile['Link'];
$fb_user->birthday = @$birthday->toString('yyyy/MM/dd');
$fb_user->gender = $user_profile['Gender'];
$fb_user->timezone = @$user_profile['Timezone'];
$fb_user->locale = @$user_profile['Locale'];
$fb_user->time_created = time();
$fb_user->time_modified = time();
$fb_user->time_social_modified = $updated_time->toValue();
$this->_id_user = $fb_user->save();
}
$this->_user = $fb_user;
$this->_id_user = $fb_user->id;
}
示例8: getExpirationDate
public function getExpirationDate($rel = null)
{
if (null === $rel) {
$rel = time();
}
// If it's a one-time payment or a free package with no duration, there
// is no expiration
if (($this->isOneTime() || $this->isFree()) && !$this->hasDuration()) {
return false;
}
// If this is a free or one-time package, the expiration is based on the
// duration, otherwise the expirations is based on the recurrence
$interval = null;
$interval_type = null;
if ($this->isOneTime() || $this->isFree()) {
$interval = $this->duration;
$interval_type = $this->duration_type;
} else {
$interval = $this->recurrence;
$interval_type = $this->recurrence_type;
}
// This is weird, it should have been handled by the statement at the top
if ($interval == 'forever') {
return false;
}
// Calculate when the next payment should be due
switch ($interval_type) {
case 'day':
$part = Zend_Date::DAY;
break;
case 'week':
$part = Zend_Date::WEEK;
break;
case 'month':
$part = Zend_Date::MONTH;
break;
case 'year':
$part = Zend_Date::YEAR;
break;
default:
throw new Engine_Payment_Exception('Invalid recurrence_type');
break;
}
$relDate = new Zend_Date($rel);
$relDate->add((int) $interval, $part);
return $relDate->toValue();
}
示例9: testToValue
/**
* Test for toValue
*/
public function testToValue()
{
$locale = new Zend_Locale('de_AT');
$date = new Zend_Date(1234567890, false, $locale);
$this->assertSame($date->toValue(), 1234567890);
$this->assertSame($date->toValue(Zend_Date::DAY), 14);
$this->assertSame($date->toValue(Zend_Date::DAY, true), 13);
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_SHORT), false);
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_SHORT, true), false);
$this->assertSame($date->toValue(Zend_Date::DAY_SHORT), 14);
$this->assertSame($date->toValue(Zend_Date::DAY_SHORT, true), 13);
$this->assertSame($date->toValue(Zend_Date::WEEKDAY), false);
$this->assertSame($date->toValue(Zend_Date::WEEKDAY, true), false);
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_8601), 6);
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_8601, true), 5);
$this->assertSame($date->toValue(Zend_Date::DAY_SUFFIX), false);
$this->assertSame($date->toValue(Zend_Date::DAY_SUFFIX, true), false);
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_DIGIT), 6);
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_DIGIT, true), 5);
$this->assertSame($date->toValue(Zend_Date::DAY_OF_YEAR), 44);
$this->assertSame($date->toValue(Zend_Date::DAY_OF_YEAR, true), 43);
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_NARROW), false);
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_NARROW, true), false);
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_NAME), false);
$this->assertSame($date->toValue(Zend_Date::WEEKDAY_NAME, true), false);
$this->assertSame($date->toValue(Zend_Date::WEEK), 7);
$this->assertSame($date->toValue(Zend_Date::WEEK, true), 7);
$this->assertSame($date->toValue(Zend_Date::MONTH), false);
$this->assertSame($date->toValue(Zend_Date::MONTH, true), false);
$this->assertSame($date->toValue(Zend_Date::MONTH_SHORT), 2);
$this->assertSame($date->toValue(Zend_Date::MONTH_SHORT, true), 2);
$this->assertSame($date->toValue(Zend_Date::MONTH_NAME), false);
$this->assertSame($date->toValue(Zend_Date::MONTH_NAME, true), false);
$this->assertSame($date->toValue(Zend_Date::MONTH_DIGIT), 2);
$this->assertSame($date->toValue(Zend_Date::MONTH_DIGIT, true), 2);
$this->assertSame($date->toValue(Zend_Date::MONTH_DAYS), 28);
$this->assertSame($date->toValue(Zend_Date::MONTH_DAYS, true), 28);
$this->assertSame($date->toValue(Zend_Date::MONTH_NARROW), false);
$this->assertSame($date->toValue(Zend_Date::MONTH_NARROW, true), false);
$this->assertSame($date->toValue(Zend_Date::LEAPYEAR), 0);
$this->assertSame($date->toValue(Zend_Date::LEAPYEAR, true), 0);
$this->assertSame($date->toValue(Zend_Date::YEAR_8601), 2009);
$this->assertSame($date->toValue(Zend_Date::YEAR_8601, true), 2009);
$this->assertSame($date->toValue(Zend_Date::YEAR), 2009);
$this->assertSame($date->toValue(Zend_Date::YEAR, true), 2009);
$this->assertSame($date->toValue(Zend_Date::YEAR_SHORT), 9);
$this->assertSame($date->toValue(Zend_Date::YEAR_SHORT, true), 9);
$this->assertSame($date->toValue(Zend_Date::YEAR_SHORT_8601), 9);
$this->assertSame($date->toValue(Zend_Date::YEAR_SHORT_8601, true), 9);
$this->assertSame($date->toValue(Zend_Date::MERIDIEM), false);
$this->assertSame($date->toValue(Zend_Date::MERIDIEM, true), false);
$this->assertSame($date->toValue(Zend_Date::SWATCH), 21);
$this->assertSame($date->toValue(Zend_Date::SWATCH, true), 21);
$this->assertSame($date->toValue(Zend_Date::HOUR_SHORT_AM), 12);
$this->assertSame($date->toValue(Zend_Date::HOUR_SHORT_AM, true), 11);
$this->assertSame($date->toValue(Zend_Date::HOUR_SHORT), 0);
$this->assertSame($date->toValue(Zend_Date::HOUR_SHORT, true), 23);
$this->assertSame($date->toValue(Zend_Date::HOUR_AM), 12);
$this->assertSame($date->toValue(Zend_Date::HOUR_AM, true), 11);
$this->assertSame($date->toValue(Zend_Date::HOUR), 0);
$this->assertSame($date->toValue(Zend_Date::HOUR, true), 23);
$this->assertSame($date->toValue(Zend_Date::MINUTE), 31);
$this->assertSame($date->toValue(Zend_Date::MINUTE, true), 31);
$this->assertSame($date->toValue(Zend_Date::SECOND), 30);
$this->assertSame($date->toValue(Zend_Date::SECOND, true), 30);
$this->assertSame($date->toValue(Zend_Date::MILLISECOND), 0);
$this->assertSame($date->toValue(Zend_Date::MILLISECOND, true), 0);
$this->assertSame($date->toValue(Zend_Date::MINUTE_SHORT), 31);
$this->assertSame($date->toValue(Zend_Date::MINUTE_SHORT, true), 31);
$this->assertSame($date->toValue(Zend_Date::SECOND_SHORT), 30);
$this->assertSame($date->toValue(Zend_Date::SECOND_SHORT, true), 30);
$this->assertSame($date->toValue(Zend_Date::TIMEZONE_NAME), false);
$this->assertSame($date->toValue(Zend_Date::TIMEZONE_NAME, true), false);
$this->assertSame($date->toValue(Zend_Date::DAYLIGHT), 0);
$this->assertSame($date->toValue(Zend_Date::DAYLIGHT, true), 0);
$this->assertSame($date->toValue(Zend_Date::GMT_DIFF), 100);
$this->assertSame($date->toValue(Zend_Date::GMT_DIFF, true), 0);
$this->assertSame($date->toValue(Zend_Date::GMT_DIFF_SEP), false);
$this->assertSame($date->toValue(Zend_Date::GMT_DIFF_SEP, true), false);
$this->assertSame($date->toValue(Zend_Date::TIMEZONE), false);
$this->assertSame($date->toValue(Zend_Date::TIMEZONE, true), false);
$this->assertSame($date->toValue(Zend_Date::TIMEZONE_SECS), 3600);
$this->assertSame($date->toValue(Zend_Date::TIMEZONE_SECS, true), 0);
$this->assertSame($date->toValue(Zend_Date::ISO_8601), false);
$this->assertSame($date->toValue(Zend_Date::ISO_8601, true), false);
$this->assertSame($date->toValue(Zend_Date::RFC_2822), false);
$this->assertSame($date->toValue(Zend_Date::RFC_2822, true), false);
$this->assertSame($date->toValue(Zend_Date::TIMESTAMP), 1234567890);
$this->assertSame($date->toValue(Zend_Date::TIMESTAMP, true), 1234567890);
$this->assertSame($date->toValue(Zend_Date::ERA), false);
$this->assertSame($date->toValue(Zend_Date::ERA, true), false);
$this->assertSame($date->toValue(Zend_Date::ERA_NAME), false);
$this->assertSame($date->toValue(Zend_Date::ERA_NAME, true), false);
$this->assertSame($date->toValue(Zend_Date::DATES), false);
$this->assertSame($date->toValue(Zend_Date::DATES, true), false);
$this->assertSame($date->toValue(Zend_Date::DATE_FULL), false);
$this->assertSame($date->toValue(Zend_Date::DATE_FULL, true), false);
//.........这里部分代码省略.........
示例10: _getOriginalOrderData
/**
* Check original order and return specific data (order ID, transaction ID)
*
* @return array|null
*/
protected function _getOriginalOrderData()
{
// Check original order
/** @var $session Mage_Adminhtml_Model_Session_Quote */
$session = Mage::getSingleton('adminhtml/session_quote');
if (($originalOrderId = $session->getPreviousOrderId()) || ($originalOrderId = $session->getOrderId())) {
// Get original order data
/** @var $originalOrder Mage_Sales_Model_Order */
$originalOrder = Mage::getModel('sales/order')->load($originalOrderId);
if ($originalOrder->getId()) {
$originalOrderPayment = $originalOrder->getPayment();
/** @var $helper CLS_Paypal_Helper_Data */
$helper = Mage::helper('cls_paypal');
// Check payment method for compatibility
if ($originalOrderPayment->getId() && $helper->isSupportedPaymentMethodFull($originalOrderPayment->getMethod()) && $helper->isValidParentPaymentMethod($this->_callerMethod->getCode(), $originalOrderPayment->getMethod())) {
// Select the last valid order's transaction
/** @var $transactionCollection Mage_Sales_Model_Resource_Order_Payment_Transaction_Collection */
$transactionCollection = Mage::getResourceModel('sales/order_payment_transaction_collection');
$pastDate = new Zend_Date(null);
$pastDate->addMonth(0 - CLS_Paypal_Model_Paypal_Config::STORED_CARD_TTL_MONTHS);
$transactionCollection->addOrderIdFilter($originalOrder->getId())->addPaymentIdFilter($originalOrderPayment->getId())->addAttributeToFilter('main_table.created_at', array('gt' => Mage::getModel('core/date')->gmtDate(null, $pastDate->toValue())))->setOrder('main_table.created_at', Varien_Data_Collection::SORT_ORDER_DESC);
$transaction = false;
foreach ($transactionCollection as $trans) {
if ($trans->getTxnType() !== Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND && $trans->getTxnType() !== Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID) {
$transaction = $trans;
break;
}
}
if ($transaction && !Mage::helper('cls_paypal')->transactionIsVoided($transaction)) {
return array('order_id' => $originalOrderId, 'transaction_id' => $transaction->getTxnId());
}
}
}
}
return null;
}
示例11: prepareMail
public function prepareMail()
{
// Get the current date
$now = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
// Get the setting for the start of history
$history = new Zend_Date(Mage::getStoreConfig('reminder/generalsettings/startingdate'));
// Get the settings whether to use the order creation or update date
$orderusecreation = Mage::getStoreConfig('reminder/timesettings/orderusecreation');
// Get the active stores
$storesfilter = explode(',', Mage::getStoreConfig('reminder/enablesettings/storesenabled'));
// Get all orders from the Magento database
$collection = Mage::getResourceModel('sales/order_grid_collection')->addAttributeToSelect('*')->addFieldToFilter('store_id', array('in' => $storesfilter))->addAttributeToFilter('created_at', array('from' => $history, 'to' => $now, 'datetime' => true));
#->addAttributeToFilter( 'status', array( 'in' => $statusfilter ) )
// Iterate over all the orders
$remindermodel = Mage::getModel('reminder/reminder');
$orders = $collection->getItems();
$count_all = count($orders);
$count_considered1 = 0;
$count_considered2 = 0;
$count_match = 0;
foreach ($orders as $order) {
// Get settings for the status filter
$statusfilter = explode(',', Mage::getStoreConfig('reminder/generalsettings/orderstatuses', $order->getStoreId()));
// Only consider orders with the right status
$statusok = in_array($order->getStatus(), $statusfilter);
if ($statusok) {
$count_considered1 += 1;
// Get settings for weekend days
$weekendsexclude = Mage::getStoreConfig('reminder/timesettings/weekendsexclude', $order->getStoreId());
// Get settings for the payment filters
$paymentfilter = explode(',', Mage::getStoreConfig('reminder/generalsettings/orderpayments', $order->getStoreId()));
// Get settings for onaccount customers
$firstnotificationonaccount = Mage::getStoreConfig('reminder/timesettings/firstnotificationonaccount', $order->getStoreId());
$firstonaccount = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
$firstonaccount = $firstonaccount->subDay($firstnotificationonaccount);
$secondnotificationonaccount = Mage::getStoreConfig('reminder/timesettings/secondnotificationonaccount', $order->getStoreId());
$secondonaccount = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
$secondonaccount = $secondonaccount->subDay($secondnotificationonaccount);
$nthonaccount = Mage::getStoreConfig('reminder/timesettings/nthonaccount', $order->getStoreId());
$cancelonaccountsettings = Mage::getStoreConfig('reminder/timesettings/cancelonaccount', $order->getStoreId());
$cancelonaccount = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
$cancelonaccount = $cancelonaccount->subDay($cancelonaccountsettings);
// Get settings for prepaid customers
$firstnotificationprepaid = Mage::getStoreConfig('reminder/timesettings/firstnotificationprepaid', $order->getStoreId());
$firstprepaid = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
$firstprepaid = $firstprepaid->subDay($firstnotificationprepaid);
$secondnotificationprepaid = Mage::getStoreConfig('reminder/timesettings/secondnotificationprepaid', $order->getStoreId());
$secondprepaid = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
$secondprepaid = $secondprepaid->subDay($secondnotificationprepaid);
$nthprepaid = Mage::getStoreConfig('reminder/timesettings/nthprepaid', $order->getStoreId());
$cancelprepaidsettings = Mage::getStoreConfig('reminder/timesettings/cancelprepaid', $order->getStoreId());
$cancelprepaid = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
$cancelprepaid = $cancelprepaid->subDay($cancelprepaidsettings);
// Get the order from the 'reminder' database
$reminderorders = $remindermodel->getCollection()->addFieldToFilter('increment_id', $order->getIncrementId())->getItems();
// If it doesn't exist yet, create it
if (empty($reminderorders)) {
$this->createReminderEntry($order, $remindermodel);
$reminderorders = $remindermodel->getCollection()->addFieldToFilter('increment_id', $order->getIncrementId())->getItems();
}
// Process the order as present in the 'reminder' database
foreach ($reminderorders as $reminderorder) {
// Make sure that the order is not filtered out - otherwise don't do any processing
if ($reminderorder->getStatus() == 'enabled' && $order->getBillingAddress() != null && in_array($order->getPayment()->getMethod(), $paymentfilter)) {
$count_considered2 += 1;
// Obtain the age (weekends excluded)
if ($weekendsexclude == 'enabled') {
// Obtain the age
$now_bis = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
if ($orderusecreation == 'enabled') {
$start_date = new Zend_Date($order->getCreatedAt(), 'yyyy-MM-dd');
} else {
$start_date = new Zend_Date($order->getUpdatedAt(), 'yyyy-MM-dd');
}
$age = $now_bis->sub($start_date)->toValue();
$days = ceil($age / 60 / 60 / 24);
// Calculate the weekenddays
$end_date = new Zend_Date($start_date);
$dayscounter = $days;
$weekenddays = 0;
while ($dayscounter > 0) {
$weekdaydigit = $end_date->toValue(Zend_Date::WEEKDAY_DIGIT);
if ($weekdaydigit == 0 || $weekdaydigit == 6) {
$weekenddays++;
}
$end_date->addDay(1);
$dayscounter--;
}
} else {
$weekenddays = 0;
}
// Get the date of the order
if ($orderusecreation == 'enabled') {
$orderdate = new Zend_Date($order->getCreatedAt(), 'yyyy-MM-dd');
} else {
$orderdate = new Zend_Date($order->getUpdatedAt(), 'yyyy-MM-dd');
}
$orderdate = $orderdate->addDay($weekenddays);
$orderdate = $orderdate->getTimestamp();
// Find out if the order is part of the on-account customers
//.........这里部分代码省略.........
示例12: updateFeedPosts
/**
* Get the latest posts from a feed
*
* @param Feed $feed
*/
protected function updateFeedPosts(Feed $feed)
{
$feedSource = Zend_Feed_Reader::import($feed->url);
$posts = new Posts();
$tdate = $feedSource->current()->getDateModified();
$tdate = new Zend_Date($tdate);
$defaultFilterChain = new Zend_Filter();
$defaultFilterChain->addFilter(new Ifphp_Filter_XSSClean());
$defaultFilterChain->addFilter(new Zend_Filter_StringTrim());
$defaultFilterChain->addFilter(new Zend_Filter_StripTags());
$defaultFilterChain->addFilter(new Zend_Filter_HtmlEntities(array('quotestyle' => ENT_QUOTES, 'charset' => 'UTF-8')));
$defaultFilterChain->addFilter(new Ifphp_Filter_HtmlEntityNames());
while ($feedSource->valid() && $tdate->toValue() > $feed->lastPing && !$posts->getByLink($feedSource->current()->getPermaLink())) {
$tdate = $feedSource->current()->getDateModified();
$tdate = new Zend_Date($tdate);
$post = $posts->createRow();
$post->title = $defaultFilterChain->filter($feedSource->current()->getTitle());
$post->description = $defaultFilterChain->filter($feedSource->current()->getDescription());
$post->feedId = $defaultFilterChain->filter($feed->id);
$post->link = $defaultFilterChain->filter($feedSource->current()->getPermaLink());
$post->publishDate = $tdate->toValue();
$post->save();
Ifphp_Controller_Front::getInstance()->getPluginBroker()->addPost($post, $feed);
$feedSource->next();
}
$feed->lastPing = time();
$feed->save();
}
示例13: getMonthNumber
protected function getMonthNumber($donation)
{
$date = new Zend_Date($donation->getCreatedAt());
return $date->toValue(Zend_Date::MONTH_SHORT);
}
示例14: getPredefinedRange
/**
* 取得某个预定义时间段
*
* @static
* @param integer $interval
* @param string $forceUnit
* @param integer $timestamp
* @return array
*/
public static function getPredefinedRange($interval, $forceUnit = null, $timestamp = null)
{
if (empty($timestamp)) {
$timestamp = time();
}
$start = new Zend_Date($timestamp);
$end = new Zend_Date($timestamp);
switch ($interval) {
case self::TODAY:
$start->setHour(0)->setMinute(0)->setSecond(0);
$unit = Zend_Date::HOUR;
break;
case self::YESTODAY:
$start->subDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end = clone $start;
$end->addDay(1);
$unit = Zend_Date::HOUR;
break;
case self::TOMORROW:
$start->addDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end = clone $start;
$end->addDay(1);
$unit = Zend_Date::HOUR;
break;
case self::THIS_MONTH:
$start->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$unit = Zend_Date::DAY;
break;
case self::THIS_YEAR:
$start->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end->addMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$unit = Zend_Date::DAY;
break;
case self::THIS_SEASON:
$start->setMonth(3 * floor(($start->toValue('M') - 1) / 3) + 1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$unit = Zend_Date::DAY;
case self::RECENT_24HOUR:
$start->subHour(24);
$unit = Zend_Date::HOUR;
break;
case self::RECENT_48HOUR:
$start->subHour(48);
$unit = Zend_Date::HOUR;
break;
case self::RECENT_1WEEK:
$start->subWeek(1);
$unit = Zend_Date::DAY;
break;
case self::RECENT_1MONTH:
$start->subMonth(1);
$unit = Zend_Date::DAY;
break;
case self::RECENT_24MONTH:
$start->subMonth(24);
$unit = Zend_Date::DAY;
break;
case self::LAST_1MONTH:
$start->subMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end = clone $start;
$end->addMonth(1);
$unit = Zend_Date::DAY;
break;
case self::LAST_1YEAR:
$start->subYear(1)->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
$end = clone $start;
$end->addYear(1);
$unit = Zend_Date::DAY;
break;
case self::ENTIRE_DAY:
$start->setDate(self::ERA_DATE, self::ZF_DATE_FORMAT)->setTime(self::ERA_TIME, self::ZF_TIME_FORMAT);
$end->addDay(1);
$unit = Zend_Date::DAY;
break;
default:
$unit = Zend_Date::SECOND;
}
if (!empty($forceUnit)) {
$unit = $forceUnit;
}
$start = max(self::truncateDatetime($start, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
$end = max(self::truncateDatetime($end, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
return compact('start', 'end', 'unit');
}
示例15: _updateUserDb
protected function _updateUserDb()
{
$userData = HTS_Util::getObjectFileCache()->load('user_' . $this->_id_social);
if ($userData === false) {
$user_db = HTS_Util::getDbTable('users');
$user = $user_db->findOneByIdSocial($this->_id_social);
if (empty($user)) {
$user_profile = $this->getUserProfile();
$user = HTS_Util::getDbRow('users');
//TODO some values are null -> undefined index warning
if (!empty($user_profile['birthday'])) {
$birthday = new Zend_Date(@$user_profile['birthday'], 'dd/MM/yyyy');
$user->birthday = @$birthday->toString('yyyy/MM/dd');
}
$updated_time = new Zend_Date($user_profile['updated_time']);
$user->id_social = $user_profile['id'];
$user->name = $user_profile['name'];
$user->email = @$user_profile['email'];
$user->first_name = $user_profile['first_name'];
$user->middle_name = @$user_profile['middle_name'];
$user->last_name = @$user_profile['last_name'];
$user->link = $user_profile['link'];
$user->image = 'http://graph.facebook.com/' . $user_profile['id'] . '/picture';
$user->gender = $user_profile['gender'];
$user->timezone = $user_profile['timezone'];
$user->locale = $user_profile['locale'];
$user->time_created = time();
$user->time_modified = time();
$user->time_social_modified = $updated_time->toValue();
}
$user->save();
HTS_Util::getObjectFileCache()->save($user->toArray(), 'user_' . $this->_id_social);
} else {
$user_db = HTS_Util::getDbTable('users');
$user = $user_db->createRow($userData);
}
$this->_user = $user;
$this->_id_user = $user->id;
}