src/Seboettg/CiteProc/Util/DateHelper.php
public static function getSortKeyDate($dataItem, $key)
    {
        $variable = $variable = $key->getVariable();
        $part = $key->getRangePart();
        if (count($dataItem->{$variable}->{'date-parts'}) > 1) {
            //Date range
            $datePart = $dataItem->{$variable}->{'date-parts'}[$part];
            $sortKey = self::serializeDate($datePart);
            if ($key->getSort() === "descending" && $part === 0 ||
                $key->getSort() === "ascending" && $part === 1) {
                $sortKey .= "-";
            }
        } else {

            if (!isset($dataItem->{$variable}->{'date-parts'})) {
                $dateParts = self::parseDateParts($dataItem->{$variable});
            } else {
                $dateParts = $dataItem->{$variable}->{'date-parts'}[0];
            }
            $sortKey = self::serializeDate($dateParts);
        }
        return $sortKey;
    }
public static function getSortKeyDate($dataItem, $key)
    {
        $variable = $variable = $key->getVariable();
        $part = $key->getRangePart();
        if (count($dataItem->{$variable}->{'date-parts'}) > 1) {
            //Date range
            $datePart = $dataItem->{$variable}->{'date-parts'}[$part];
            $sortKey = self::serializeDate($datePart);
            if ($key->getSort() === "descending" && $part === 0 ||
                $key->getSort() === "ascending" && $part === 1) {
                $sortKey .= "-";
            }
        } else {

            if (!isset($dataItem->{$variable}->{'date-parts'})) {
                $dateParts = self::parseDateParts($dataItem->{$variable});
            } else {
                $dateParts = $dataItem->{$variable}->{'date-parts'}[0];
            }
            $sortKey = self::serializeDate($dateParts);
        }
        return $sortKey;
    }
public static function getSortKeyDate ( $ dataItem , $ key ) { $ variable = $ variable = $ key -> getVariable ( ) ; $ part = $ key -> getRangePart ( ) ; if ( count ( $ dataItem -> { $ variable } -> { 'date-parts' } ) > 1 ) { //Date range $ datePart = $ dataItem -> { $ variable } -> { 'date-parts' } [ $ part ] ; $ sortKey = self :: serializeDate ( $ datePart ) ; if ( $ key -> getSort ( ) === "descending" && $ part === 0 || $ key -> getSort ( ) === "ascending" && $ part === 1 ) { $ sortKey .= "-" ; } } else { if ( ! isset ( $ dataItem -> { $ variable } -> { 'date-parts' } ) ) { $ dateParts = self :: parseDateParts ( $ dataItem -> { $ variable } ) ; } else { $ dateParts = $ dataItem -> { $ variable } -> { 'date-parts' } [ 0 ] ; } $ sortKey = self :: serializeDate ( $ dateParts ) ; } return $ sortKey ; }
creates sort key for variables containing date and date ranges
@param array $dataItem
@param Key $key
@return string
@throws CiteProcException
creates sort key for variables containing date and date ranges