public function setEnd($end, $write=true)
    {
        $e = $this;

        if ($e->TimeFrameType == 'DateTime') {
            $e->EndDateTime = $end;
        } elseif ($e->TimeFrameType == 'Duration') {
            $duration = $this->calcDurationBasedOnEndDateTime($end);
            if ($duration) {
                $e->Duration = $duration;
            } else {
                //if duration is more than 1 day, make the time frame "DateTime"
                $e->TimeFrameType = 'DateTime';
                $e->EndDateTime = $end;
            }
        }

        if ($write) {
            $e->write();
        }
    }