private function get_time_duration_from_form_data(\stdClass $data) {
        if ($data->duration == 1) {
            return $data->timedurationuntil - $data->timestart;
        } else if ($data->duration == 2) {
            return $data->timedurationminutes * MINSECS;
        } else {
            return 0;
        }
    }