本文整理汇总了PHP中QDateTime::SetTime方法的典型用法代码示例。如果您正苦于以下问题:PHP QDateTime::SetTime方法的具体用法?PHP QDateTime::SetTime怎么用?PHP QDateTime::SetTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTime
的用法示例。
在下文中一共展示了QDateTime::SetTime方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ParsePostData
public function ParsePostData()
{
$blnChanged = false;
$dttNewDateTime = new QDateTime();
// Update Date Component
switch ($this->strCalendarType) {
case QCalendarType::DateOnly:
case QCalendarType::DateTime:
case QCalendarType::DateTimeSeconds:
$strKey = $this->strControlId . "_intTimestamp";
if (array_key_exists($strKey, $_POST)) {
// If no date was set, set to null and return
$intTimestamp = $_POST[$strKey];
if (!$intTimestamp) {
$this->intTimestamp = null;
return;
}
// Otherwise, set up a new date object, and update dttNewDateTime accordingly
$blnChanged = true;
$dttSelectedDate = QDateTime::FromTimestamp($_POST[$strKey]);
$dttNewDateTime->SetDate($dttSelectedDate->Year, $dttSelectedDate->Month, $dttSelectedDate->Day);
}
}
// Update Time Component
switch ($this->strCalendarType) {
case QCalendarType::TimeOnly:
case QCalendarType::TimeSecondsOnly:
case QCalendarType::DateTime:
case QCalendarType::DateTimeSeconds:
// Hour
$strKey = $this->strControlId . "_intHour";
if (array_key_exists($strKey, $_POST)) {
$blnChanged = true;
$dttNewDateTime->SetTime($_POST[$strKey], $dttNewDateTime->Minute, $dttNewDateTime->Second);
}
// Minute
$strKey = $this->strControlId . "_intMinute";
if (array_key_exists($strKey, $_POST)) {
$blnChanged = true;
$dttNewDateTime->SetTime($dttNewDateTime->Hour, $_POST[$strKey], $dttNewDateTime->Second);
}
// Second
$strKey = $this->strControlId . "_intSecond";
if (array_key_exists($strKey, $_POST)) {
$blnChanged = true;
$dttNewDateTime->SetTime($dttNewDateTime->Hour, $dttNewDateTime->Minute, $_POST[$strKey]);
}
}
// Update local intTimestamp
$this->intTimestamp = $dttNewDateTime->Timestamp;
}
示例2: dtgItems_Bind
public function dtgItems_Bind()
{
$intYear = QApplication::PathInfo(0);
$dttStart = new QDateTime($intYear . '-01-01');
$dttEnd = new QDateTime($dttStart);
$dttEnd->Year += 1;
$dttStart->SetTime(null, null, null);
$dttEnd->SetTime(null, null, null);
$objPersonCursor = Person::QueryCursor(QQ::AndCondition(QQ::GreaterOrEqual(QQN::Person()->StewardshipContribution->DateCredited, $dttStart), QQ::LessThan(QQN::Person()->StewardshipContribution->DateCredited, $dttEnd)), QQ::Clause(QQ::Distinct(), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
$strNameArray = array();
$strNameValueArray = array();
while ($objPerson = Person::InstantiateCursor($objPersonCursor)) {
$strToken = strtolower($objPerson->FirstName . '|' . $objPerson->LastName);
$strToken = str_replace(' ', '', $strToken);
$strToken = str_replace('.', '', $strToken);
$strToken = str_replace(',', '', $strToken);
$strToken = str_replace('-', '', $strToken);
$strToken = str_replace('_', '', $strToken);
$strToken = str_replace('/', '', $strToken);
if (array_key_exists($strToken, $strNameArray)) {
$strNameValueArray[$strToken] = $objPerson->FirstName . ' ' . $objPerson->LastName;
}
$strNameArray[$strToken] = true;
}
$this->dtgItems->DataSource = $strNameValueArray;
}
示例3: __get
public function __get($strName)
{
switch ($strName) {
case 'DateRange':
return sprintf('Takes place from %s to %s', $this->dttDateStart->ToString('MMM D'), $this->dttDateEnd->ToString('MMM D'), $this->MeetsOnInfo);
case 'MeetsOnInfo':
if (!is_null($this->intMeetingDay) && !is_null($this->intMeetingStartTime) && !is_null($this->intMeetingEndTime)) {
$strArray = array(0 => 'Sunday', 1 => 'Monday', 2 => 'Tuesday', 3 => 'Wednesday', 4 => 'Thursday', 5 => 'Friday', 6 => 'Saturday');
$dttStart = new QDateTime();
$dttEnd = new QDateTime();
$dttStart->SetTime(floor($this->intMeetingStartTime / 100), $this->intMeetingStartTime % 100, 0);
$dttEnd->SetTime(floor($this->intMeetingEndTime / 100), $this->intMeetingEndTime % 100, 0);
return sprintf('%ss, %s to %s', $strArray[$this->intMeetingDay], $dttStart->ToString('h:mmz'), $dttEnd->ToString('h:mmz'));
} else {
return 'TBA';
}
default:
try {
return parent::__get($strName);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
示例4: GenerateStewardship
public static function GenerateStewardship()
{
$dttDate = new QDateTime('2004-01-05');
print 'Generating Stewardship... ';
$objFundArray = StewardshipFund::QueryArray(QQ::NotEqual(QQN::StewardshipFund()->Id, 1));
while ($dttDate->IsEarlierThan(QDateTime::Now())) {
print $strDate = '[' . $dttDate->ToString('YYYY-MMM-DD') . ']';
$intCheckCount = rand(10, 55);
$arrStack = array();
for ($i = 0; $i < floor(($intCheckCount - 1) / 25) + 1; $i++) {
$arrStack[] = null;
}
$objBatch = StewardshipBatch::Create(self::GenerateFromArray(self::$StewardshipUserArray), $arrStack, self::GenerateFromArray(array('Weekend T/O', 'Weekend Giving', 'Tithes and Offerings', 'Tithes & Offerings', null)), $dttDate, $dttDate);
$intStackCount = $objBatch->CountStewardshipStacks();
$dttStart = new QDateTime($dttDate);
$dttStart->SetTime(8, 0, 0);
$dttEnd = new QDateTime($dttDate);
$dttEnd->SetTime(16, 0, 0);
for ($i = 0; $i < $intStackCount; $i++) {
if ($i == $intStackCount - 1) {
if ($intCheckCount % 25 == 0) {
$intChecksInStackCount = 25;
} else {
$intChecksInStackCount = $intCheckCount % 25;
}
} else {
$intChecksInStackCount = 25;
}
$objStack = StewardshipStack::LoadByStewardshipBatchIdStackNumber($objBatch->Id, $i + 1);
for ($j = 0; $j < $intChecksInStackCount; $j++) {
$objHousehold = self::GenerateFromArray(self::$HouseholdArray);
$objHouseholdParticipant = self::GenerateFromArray($objHousehold->GetHouseholdParticipationArray());
$mixAmountArray = array();
if (rand(0, 50)) {
$mixAmountArray[] = array(1, rand(1000, 150000) / 100);
} else {
$mixAmountArray[] = array(self::GenerateFromArray($objFundArray)->Id, rand(1000, 150000) / 100);
}
if (!rand(0, 20)) {
$mixAmountArray[] = array(self::GenerateFromArray($objFundArray)->Id, rand(1000, 150000) / 100);
}
$objContribution = StewardshipContribution::Create($objBatch->CreatedByLogin, $objHouseholdParticipant->Person, $objStack, StewardshipContributionType::Check, rand(1000, 9999), $mixAmountArray, self::GenerateDateTime($dttStart, $dttEnd), null, null, null, false);
if (rand(0, 5)) {
$objContribution->SaveImageFile(__DEVTOOLS_CLI__ . '/datagen_file_assets/check.tif');
}
}
$objStack->RefreshActualTotalAmount();
}
if ($intCheckCount != $objBatch->CountStewardshipContributions()) {
print "\r\n" . 'MISCOUNT: ' . $objBatch->Id . "\r\n";
}
$objBatch->RefreshActualTotalAmount();
$dttDate->Day += 7;
print str_repeat(chr(8) . ' ' . chr(8), strlen($strDate));
}
print "Done.\r\n";
}
示例5: dtgItems_Bind
public function dtgItems_Bind()
{
$intYear = QApplication::PathInfo(0);
$dttStart = new QDateTime($intYear . '-01-01');
$dttEnd = new QDateTime($dttStart);
$dttEnd->Year += 1;
$dttStart->SetTime(null, null, null);
$dttEnd->SetTime(null, null, null);
$this->dtgItems->DataSource = Person::QueryArray(QQ::AndCondition(QQ::GreaterOrEqual(QQN::Person()->StewardshipContribution->DateCredited, $dttStart), QQ::LessThan(QQN::Person()->StewardshipContribution->DateCredited, $dttEnd), QQ::IsNull(QQN::Person()->PrimaryAddressText), QQ::IsNull(QQN::Person()->StewardshipAddressId)), QQ::Clause(QQ::Distinct(), QQ::OrderBy(QQN::Person()->LastName, QQN::Person()->FirstName)));
}
示例6: __get
public function __get($strName)
{
switch ($strName) {
case 'GeneratedDescription':
if ($this->strLocation || $this->dttDateStart || $this->dttDateEnd) {
$strToReturn = ', to be held';
if ($this->strLocation) {
$strToReturn .= ' at ' . $this->strLocation;
}
if ($this->dttDateStart && $this->dttDateEnd) {
$dttCompare1 = new QDateTime($this->dttDateStart);
$dttCompare2 = new QDateTime($this->dttDateEnd);
$dttCompare1->SetTime(null, null, null);
$dttCompare2->SetTime(null, null, null);
if ($dttCompare1->IsEqualTo($dttCompare2)) {
$strToReturn .= ' on ' . $this->dttDateStart->ToString('MMMM D YYYY');
$strToReturn .= ' from ' . $this->dttDateStart->ToString('h:mm z');
$strToReturn .= ' to ' . $this->dttDateEnd->ToString('h:mm z');
} else {
$strToReturn .= ' from ' . $this->dttDateStart->ToString('MMMM D');
$strToReturn .= ' to ' . $this->dttDateEnd->ToString('MMMM D YYYY');
}
} else {
if ($this->dttDateStart) {
$strToReturn .= ' on ' . $this->dttDateStart->ToString('MMMM D YYYY');
if ($this->dttDateStart->Hour || $this->dttDateStart->Minute) {
$strToReturn .= ' @ ' . $this->dttDateStart->ToString('h:mm z');
}
} else {
if ($this->dttDateEnd) {
$strToReturn .= ' until ' . $this->dttDateEnd->ToString('MMMM D YYYY');
if ($this->dttDateStart->Hour || $this->dttDateEnd->Minute) {
$strToReturn .= ' @ ' . $this->dttDateEnd->ToString('h:mm z');
}
}
}
}
return $strToReturn;
} else {
return null;
}
break;
default:
try {
return parent::__get($strName);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
示例7: GetReportYtdByFundForMonth
/**
* Returns an array of 2-item arrays, where each item has the following index:
* 0: stewardship_fund_id
* 1; total amount YTD
* for a given month
* @param QDateTime $dttMonth
* @return string[][]
*/
public static function GetReportYtdByFundForMonth(QDateTime $dttMonth)
{
$dttMonth->Day = 1;
$dttMonth->SetTime(null, null, null);
$dttNextMonth = new QDateTime($dttMonth);
$dttNextMonth->Month++;
$dttNextMonth->SetTime(null, null, null);
$dttMonth->Month = 1;
$objResult = StewardshipPostAmount::GetDatabase()->Query(sprintf("SELECT stewardship_fund_id, SUM(amount) AS sum_amount FROM stewardship_post_amount, stewardship_post, stewardship_batch WHERE\n\t\t\t\tstewardship_batch_id=stewardship_batch.id AND\n\t\t\t\tstewardship_post_id=stewardship_post.id AND date_credited >= '%s' AND date_credited < '%s' GROUP BY stewardship_fund_id ORDER BY SUM(amount) DESC;", $dttMonth->ToString('YYYY-MM-DD'), $dttNextMonth->ToString('YYYY-MM-DD')));
$strToReturn = array();
while ($objRow = $objResult->GetNextRow()) {
$strToReturn[] = array($objRow->GetColumn('stewardship_fund_id'), $objRow->GetColumn('sum_amount'));
}
return $strToReturn;
}
示例8: Create
/**
* Creates a new StewardshipBatch with a given description and Batch Date. Will use Now() if no date is specified.
* @param Login $objLogin the login responsible for creating this
* @param float $fltReportedTotalAmountArray[] optional
* @param string $strDescription optional
* @param QDateTime $dttBatchDate optional, or will use Now() if null
* @param QDateTime $dttDateCredited optional, or will use $dttBatchDate if null
* @return StewardshipBatch
*/
public static function Create(Login $objLogin, $fltReportedTotalAmountArray = null, $strDescription = null, QDateTime $dttBatchDate = null, QDateTime $dttDateCredited = null)
{
if (!$dttBatchDate) {
$dttBatchDate = QDateTime::Now();
} else {
$dttBatchDate = new QDateTime($dttBatchDate);
}
$dttBatchDate->SetTime(null, null, null);
if (!$dttDateCredited) {
$dttDateCredited = new QDateTime($dttBatchDate);
} else {
$dttDateCredited = new QDateTime($dttDateCredited);
}
$dttDateCredited->SetTime(null, null, null);
$objBatch = new StewardshipBatch();
$objBatch->CreatedByLogin = $objLogin;
$objBatch->StewardshipBatchStatusTypeId = StewardshipBatchStatusType::NewBatch;
$objBatch->DateEntered = $dttBatchDate;
$objBatch->DateCredited = $dttDateCredited;
$objCurrentLastLetter = StewardshipBatch::QuerySingle(QQ::Equal(QQN::StewardshipBatch()->DateEntered, $dttBatchDate), QQ::OrderBy(QQN::StewardshipBatch()->BatchLabel, false));
if ($objCurrentLastLetter) {
$objBatch->BatchLabel = chr(ord($objCurrentLastLetter->BatchLabel) + 1);
} else {
$objBatch->BatchLabel = 'A';
}
if ($fltReportedTotalAmountArray) {
$objBatch->ReportedTotalAmount = null;
foreach ($fltReportedTotalAmountArray as $fltReportedTotalAmount) {
$objBatch->ReportedTotalAmount += $fltReportedTotalAmount;
}
}
$objBatch->ActualTotalAmount = 0;
$objBatch->PostedTotalAmount = 0;
$objBatch->Description = $strDescription;
$objBatch->Save();
// Create Stacks
if ($fltReportedTotalAmountArray) {
foreach ($fltReportedTotalAmountArray as $fltReportedTotalAmount) {
$objBatch->CreateStack($fltReportedTotalAmount);
}
}
return $objBatch;
}
示例9: __get
public function __get($strName) {
switch ($strName) {
// MISC
case "DateTime":
if ($this->intTimestamp) {
$dttToReturn = new QDateTime($this->intTimestamp);
$dttToReturn->SetTime(null, null, null);
return $dttToReturn;
} else {
return null;
}
case "CalendarType":
return $this->strCalendarType;
// case "MinimumDate": return $this->dttMinimumDate;
// case "MaximumDate": return $this->dttMaximumDate;
default:
try {
return parent::__get($strName);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
示例10: testSetProperties
public function testSetProperties()
{
$obj1 = new QDateTime();
$obj1->setDate(2002, 3, 15);
$this->assertTrue($obj1->IsTimeNull(), "Setting only a date after null constructor keeps time null");
$obj2 = new QDateTime("2002-03-15");
$obj3 = new QDateTime("2002-03-15 13:15");
$obj4 = new QDateTime("2002-03-16");
$this->assertTrue($obj1->IsEqualTo($obj2));
$this->assertTrue($obj1->IsEqualTo($obj3));
// dates are the same!
$this->assertFalse($obj3->IsEqualTo($obj4));
// dates are different!
$obj5 = new QDateTime('13:15:02', null, QDateTime::TimeOnlyType);
$this->assertTrue($obj5->IsDateNull(), "Setting only a date after null constructor keeps time null");
$obj6 = new QDateTime('2002-03-15 13:15:02');
$obj1->SetTime($obj5);
$this->assertFalse($obj1->IsTimeNull(), "Setting a time with object results in a change in null time status");
$this->assertTrue($obj1->IsEqualTo($obj6), "SetTime correctly combines date only and time only values");
}