Menu

#4 CDate::compare() is inverted from Date::compare

open
nobody
None
5
2006-11-06
2006-11-06
Dan
No

Heh.

$startdate = 0;
$enddate = 2;
$holiday = 1;

Badness:
if (CDate::compare($holiday, $startdate) > 0 &&
CDate::compare($holiday, $enddate) < 0) {
if ($startdate - $holiday > 0 && $enddate - $holiday < 0)
if ((0-1) > 0 && (2 - 1) < 0)

Goodness:
if (($holiday - $startdate) > 0) && (($holiday -
$enddate) < 0)
if (1-0 > 0 && (1 - 2) < 0) {

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.