PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Date and Time » Calendar » Bug #1995

thisWeek, prevWeek, nextWeek not affected when set new timestamp

Details

Submitted2004-07-27 13:42 UTC
Fromjohnschaefer at gmx dot de
Assignedquipo
StatusClosed
PackageCalendar
PHP VersionIrrelevant
OSWindows 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