. * * This file is a part of iCalcreator. */ namespace Kigkonsult\Icalcreator\Traits; use Kigkonsult\Icalcreator\Util\Util; /** * DUE property functions * * @author Kjell-Inge Gustafsson, kigkonsult * @since 2.22.23 - 2017-02-02 */ trait DUEtrait { /** * @var array component property DUE value * @access protected */ protected $due = null; /** * Return formatted output for calendar component property due * * @return string */ public function createDue() { if( empty( $this->due )) { return null; } if( Util::hasNodate( $this->due )) { return ( $this->getConfig( Util::$ALLOWEMPTY )) ? Util::createElement( Util::$DUE ) : null; } $parno = Util::isParamsValueSet( $this->due, Util::$DATE ) ? 3 : null; return Util::createElement( Util::$DUE, Util::createParams( $this->due[Util::$LCparams] ), Util::date2strdate( $this->due[Util::$LCvalue], $parno ) ); } /** * Set calendar component property due * * @param mixed $year * @param mixed $month * @param int $day * @param int $hour * @param int $min * @param int $sec * @param string $tz * @param array $params * @return bool */ public function setDue( $year, $month = null, $day = null, $hour = null, $min = null, $sec = null, $tz = null, $params = null ) { if( empty( $year )) { if( $this->getConfig( Util::$ALLOWEMPTY )) { $this->due = [ Util::$LCvalue => Util::$SP0, Util::$LCparams => Util::setParams( $params ), ]; return true; } else { return false; } } if( false === ( $tzid = $this->getConfig( Util::$TZID ))) { $tzid = null; } $this->due = Util::setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, null, null, $tzid ); return true; } }