PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Date and Time » Calendar » Bug #2382

Calendar->thisDay($asTs) returns a timestamp no matter what $asTs is

Details

Submitted2004-09-23 14:00 UTC
Fromaronnax_98 at yahoo dot com
Assignedquipo
StatusClosed
PackageCalendar
PHP Version4.3.8
OSWindows XP Home Edition SP2
Roadmaps(Not assigned)

Comments

[2004-09-23 14:00 UTC] aronnax_98 at yahoo dot com

Description:
------------
I am using Calendar-0.5.2 on Windows XP Service Pack 2. The method ->thisDay() does not behave exactly the way it is documented.

If you call it like this:

$Day->thisDay() ;

then you get the current day of the month. But if you call it like this:

$Day->thisDay(true) ;

then you get the timestamp. However, if you call it like this:

$Day->thisDay(false) ;

you should still get the current day of the month. Instead, it returns the timestamp.

I have tested this code on Mac OS X and Red Hat Linux, with several different versions of PHP. I have only encountered this discrepancy on Windows XP.

Reproduce code:
---------------
<?php
// This is the 'Just Add Hot Water' code from the Calendar

package documentation.
require_once 'Calendar/Month/Weekdays.php';

$Month = new Calendar_Month_Weekdays(date('Y'), date('n'));

$Month->build();

echo "<table>\n";

while ($Day = $Month->fetch()) {
if ($Day->isFirst()) {
echo "<tr>\n";
}

if ($Day->isEmpty()) {
echo "<td> </td>\n";
} else {
echo '<td>'.$Day->thisDay(false)."</td>\n";
}

if ($Day->isLast()) {
echo "</tr>\n";
}
}

echo "</table>\n";
?>

Expected result:
----------------
The first row of the table should look like this:

<tr>
<td> </td>
<td> </td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>

Actual result:
--------------
But it really looks like this:

<tr>
<td> </td>
<td> </td>
<td>1093996800</td>
<td>1094083200</td>
<td>1094169600</td>
<td>1094256000</td>
<td>1094342400</td>
</tr>