Home » Date and Time » Calendar » Bug #1995
thisWeek, prevWeek, nextWeek not affected when set new timestamp
Details
| Submitted | 2004-07-27 13:42 UTC |
|---|---|
| From | johnschaefer at gmx dot de |
| Assigned | quipo |
| Status | Closed |
| Package | Calendar |
| PHP Version | Irrelevant |
| OS | Windows 2000 SP4 |
| Roadmaps | (Not assigned) |
Comments
[2004-07-27 13:42 UTC] johnschaefer at gmx dot de
Description:
------------
if you set a timestamp the variable for thisWeek, prevWeek and nextWeek will not updated.
workaround:
add the following function to the Calendar_Week class
function setTimestamp($ts)
{
parent::setTimestamp($ts);
$this->thisWeek = $this->tableHelper->getWeekStart($this->year, $this->month, $this->day, $this->firstDay);
$this->prevWeek = $this->tableHelper->getWeekStart($this->year, $this->month, $this->day - $this->cE->getDaysInWeek(), $this->firstDay);
$this->nextWeek = $this->tableHelper->getWeekStart($this->year, $this->month, $this->day + $this->cE->getDaysInWeek(), $this->firstDay);
}
Reproduce code:
---------------
$week = new Calendar_Week(2000, 1, 1);
$week->setTimestamp(time());
$week->build();
echo date('W Y', $week->thisWeek(true)); // prints "51 1999", expected the current week number
echo "<br>\n";
echo date('W Y', $week->nextWeek(true)); // prints "52 2000", expected the next week number
echo "<br>\n";
echo date('W Y', $week->prevWeek(true)); // prints "50 1999", expected the last week number