Example #1
0
 /**
  * Returns date of day after given date
  *
  * @param int    $day    the day of the month, default is current local day
  * @param int    $month  the month, default is current local month
  * @param int    $year   the year in four digit format, default is current
  *                        local year
  * @param string $format the string indicating how to format the output
  *
  * @return   string     the date in the desired format
  * @access   public
  * @static
  */
 function nextDay($day = 0, $month = 0, $year = null, $format = DATE_CALC_FORMAT)
 {
     if (is_null($year)) {
         $year = Date_Calc::dateNow('%Y');
     }
     if (empty($month)) {
         $month = Date_Calc::dateNow('%m');
     }
     if (empty($day)) {
         $day = Date_Calc::dateNow('%d');
     }
     return Date_Calc::addDays(1, $day, $month, $year, $format);
 }
Example #2
0
 /**
  * Subtracts a time span from the date
  *
  * N.B. it is impossible for this function to count leap seconds,
  * because the result would be dependent on which order the consituent
  * parts of the span are subtracted from the date.  Therefore, leap
  * seconds are ignored by this function.  If you want to count leap
  * seconds, use 'subtractSeconds()'.
  *
  * @param object $span the time span to subtract
  *
  * @return   void
  * @access   public
  */
 function subtractSpan($span)
 {
     if (!is_a($span, 'Date_Span')) {
         return PEAR::raiseError("Invalid argument - not 'Date_Span' object");
     } else {
         if ($this->ob_invalidtime) {
             return $this->_getErrorInvalidTime();
         }
     }
     $hn_days = -$span->day;
     $hn_standardhour = $this->on_standardhour - $span->hour;
     $hn_standardminute = $this->on_standardminute - $span->minute;
     $hn_standardsecond = $this->on_standardsecond - $span->second;
     if ($hn_standardsecond < 0) {
         --$hn_standardminute;
         $hn_standardsecond += 60;
     }
     if ($hn_standardminute < 0) {
         --$hn_standardhour;
         $hn_standardminute += 60;
     }
     if ($hn_standardhour < 0) {
         --$hn_days;
         $hn_standardhour += 24;
     }
     list($hn_standardyear, $hn_standardmonth, $hn_standardday) = explode(" ", Date_Calc::addDays($hn_days, $this->on_standardday, $this->on_standardmonth, $this->on_standardyear, "%Y %m %d"));
     $this->setStandardTime($hn_standardday, $hn_standardmonth, $hn_standardyear, $hn_standardhour, $hn_standardminute, $hn_standardsecond, $this->on_standardpartsecond);
 }