public function testOperations2() { $obj1 = QDateTime::Now(); $obj2 = new QDateTime($obj1); // exact same time $obj1->Year = $obj1->Year + 1; $obj1->AddDays(1); $diff = $obj2->Difference($obj1); $this->assertTrue($diff->IsNegative()); $this->assertEqual($diff->Years, -1); }
/** * Returns the status (styled) of a Receipt based on it's ReceivedFlag * * @return string that says either Received or Pending */ public function __toStringStatusStyled() { if ($this->ReceivedFlag) { $strToReturn = 'Received'; } elseif ($this->DueDate && $this->DueDate->IsEarlierThan(new QDateTime(QDateTime::Now))) { $now = new QDateTime(QDateTime::Now); $dtsDifference = $now->Difference($this->DueDate); $strToReturn = sprintf('<strong style="color:#BC3500;">Pending</strong>', $dtsDifference->Days); } else { $strToReturn = '<strong style="color:#CC9933;">Pending</strong>'; } return sprintf('%s', $strToReturn); }
/** * Sets current QDateTimeSpan to the difference between two QDateTime objects * * @param QDateTime $dttFrom * @param QDateTime $dttTo */ public function SetFromQDateTime(QDateTime $dttFrom, QDateTime $dttTo) { $this->Add($dttFrom->Difference($dttTo)); }