$app->post("/user/timezones/activated", $save_timezone_activations);
$save_user_timezone_attachments = function (Request $request, Response $response) {
    $parser = new RequestParser($request);
    $data = $parser->getData();
    $errors = array();
    if (empty($data['user_id'])) {
        $errors[] = "User id should not be empty";
    }
    $user_id = $data['user_id'];
    $attach = array();
    if (!empty($data['attach'])) {
        $attach = $data['attach'];
    }
    $detach = array();
    if (!empty($data['detach'])) {
        $detach = $data['detach'];
    }
    if (empty($attach) && empty($detach)) {
        $errors[] = "Both attach and detach were empty. You must supply one or the other";
    }
    if (!empty($errors)) {
        $new_response = $response->withStatus(400);
        $r = array("errors" => $errors);
        $new_response->getBody()->write(json_encode($r));
        return $new_response;
    }
    $r = array("attach" => TimezoneRepository::createMultipleTimezoneUserRelationships($user_id, $attach), "detach" => TimezoneRepository::deleteTimezoneUserRelationship($user_id, $detach));
    $response->getBody()->write(json_encode($r));
    return $r;
};
$app->post("/user/timezones/attached", $save_user_timezone_attachments);