public function testSetProperties() { $obj1 = new QDateTime(); $obj1->setDate(2002, 3, 15); $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! }
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; } } }
/** * This will check and provide a "score" on a match against DOB, Gender and Mobile Phone Number. * The score returned will be anything from -2 to 3. * * A point is given for any item that is positively matched. * The score is negative if there is any item that does NOT match. * * In order for a match or non-match to take place, the data item needs to be defined on BOTH this person and in the data being passed in. * * @param QDateTime $dttDateOfBirth optional * @param string $strGender optional * @param string $strMobilePhone optional * @return integer */ public function ScoreDobGenderMobileMatch(QDateTime $dttDateOfBirth = null, $strGender = null, $strMobilePhone = null) { $intScore = 0; $blnNegativeFlag = false; if ($dttDateOfBirth && $this->DateOfBirth && !$this->DobGuessedFlag && !$this->DobYearApproximateFlag) { if ($dttDateOfBirth->IsEqualTo($this->DateOfBirth)) { $intScore++; } else { $blnNegativeFlag = true; } } if ($strGender && $this->Gender) { if (trim(strtoupper($strGender) == $this->Gender)) { $intScore++; } else { $blnNegativeFlag = true; } } if ($strMobilePhone && $this->CountPhones()) { $blnFound = false; foreach ($this->GetPhoneArray() as $objPhone) { if ($objPhone->PhoneTypeId != PhoneType::Home) { if ($strMobilePhone == $objPhone->Number) { $blnFound = true; } } } if ($blnFound) { $intScore++; } else { $blnNegativeFlag = true; } } return $blnNegativeFlag ? -1 * $intScore : $intScore; }
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"); }