app/Date.php
public static function compare(Date $a, Date $b): int
    {
        // Get min/max JD for each date.
        switch ($a->qual1) {
            case 'BEF':
                $amin = $a->minimumJulianDay() - 1;
                $amax = $amin;
                break;
            case 'AFT':
                $amax = $a->maximumJulianDay() + 1;
                $amin = $amax;
                break;
            default:
                $amin = $a->minimumJulianDay();
                $amax = $a->maximumJulianDay();
                break;
        }
        switch ($b->qual1) {
            case 'BEF':
                $bmin = $b->minimumJulianDay() - 1;
                $bmax = $bmin;
                break;
            case 'AFT':
                $bmax = $b->maximumJulianDay() + 1;
                $bmin = $bmax;
                break;
            default:
                $bmin = $b->minimumJulianDay();
                $bmax = $b->maximumJulianDay();
                break;
        }
        if ($amax < $bmin) {
            return -1;
        }

        if ($amin > $bmax && $bmax > 0) {
            return 1;
        }

        if ($amin < $bmin && $amax <= $bmax) {
            return -1;
        }

        if ($amin > $bmin && $amax >= $bmax && $bmax > 0) {
            return 1;
        }

        return 0;
    }
public static function compare(Date $a, Date $b): int
    {
        // Get min/max JD for each date.
        switch ($a->qual1) {
            case 'BEF':
                $amin = $a->minimumJulianDay() - 1;
                $amax = $amin;
                break;
            case 'AFT':
                $amax = $a->maximumJulianDay() + 1;
                $amin = $amax;
                break;
            default:
                $amin = $a->minimumJulianDay();
                $amax = $a->maximumJulianDay();
                break;
        }
        switch ($b->qual1) {
            case 'BEF':
                $bmin = $b->minimumJulianDay() - 1;
                $bmax = $bmin;
                break;
            case 'AFT':
                $bmax = $b->maximumJulianDay() + 1;
                $bmin = $bmax;
                break;
            default:
                $bmin = $b->minimumJulianDay();
                $bmax = $b->maximumJulianDay();
                break;
        }
        if ($amax < $bmin) {
            return -1;
        }

        if ($amin > $bmax && $bmax > 0) {
            return 1;
        }

        if ($amin < $bmin && $amax <= $bmax) {
            return -1;
        }

        if ($amin > $bmin && $amax >= $bmax && $bmax > 0) {
            return 1;
        }

        return 0;
    }
public static function compare ( Date $ a , Date $ b ) : int { // Get min/max JD for each date. switch ( $ a -> qual1 ) { case 'BEF' : $ amin = $ a -> minimumJulianDay ( ) - 1 ; $ amax = $ amin ; break ; case 'AFT' : $ amax = $ a -> maximumJulianDay ( ) + 1 ; $ amin = $ amax ; break ; default : $ amin = $ a -> minimumJulianDay ( ) ; $ amax = $ a -> maximumJulianDay ( ) ; break ; } switch ( $ b -> qual1 ) { case 'BEF' : $ bmin = $ b -> minimumJulianDay ( ) - 1 ; $ bmax = $ bmin ; break ; case 'AFT' : $ bmax = $ b -> maximumJulianDay ( ) + 1 ; $ bmin = $ bmax ; break ; default : $ bmin = $ b -> minimumJulianDay ( ) ; $ bmax = $ b -> maximumJulianDay ( ) ; break ; } if ( $ amax < $ bmin ) { return - 1 ; } if ( $ amin > $ bmax && $ bmax > 0 ) { return 1 ; } if ( $ amin < $ bmin && $ amax <= $ bmax ) { return - 1 ; } if ( $ amin > $ bmin && $ amax >= $ bmax && $ bmax > 0 ) { return 1 ; } return 0 ; }
Compare two dates, so they can be sorted.

return <0 if $a<$b
return >0 if $b>$a
return  0 if dates same/overlap
BEF/AFT sort as the day before/after

@param Date $a
@param Date $b

@return int
Compare two dates so they can be sorted .