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 » Date » Bug #9568

beginOfMonthBySpan - december, shifted one year

Details

Submitted2006-12-07 08:30 UTC
Fromgeorgbez at gmx dot net
Assignedfirman
StatusClosed
PackageDate
PHP Version5.1.1
OSWin2000
Roadmaps(Not assigned)

Comments

[2006-12-07 08:30 UTC] georgbez at gmx dot net

Description:
------------
Hi,
the method beginOfMonthBySpan has an bug. If one takes the months off, comes starting from that second year, always in December a wrong year. It is shifted one year.

Best regards,
Georg Bez

Test script:
---------------
<?php
require_once 'Date/Calc.php';

$tag = date( 'd' );
$out = '';

$date = new Date_Calc();

for ($i = 1; $i <= 40; $i++) {
$von = $date->beginOfMonthBySpan( -($i), null, null, "%d.%m.%Y" );
$von = explode( '.', $von );

$s = $i.' - '.sprintf( "%s.%s.%s", $tag, $von[1], $von[2] );

if( $von[1] == 12 ) {
$out .= '<b>'.$s.'</b>';
} else {
$out .= $s;
}

$out .= "<br>";

}

echo $out;
?>

Actual result:
--------------
12 - 07.12.2005
...
24 - 07.12.2005
...
36 - 07.12.2004
...