<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def confirm_user(query):
 """ Confirm a user account. """

    user = _query_to_user(query)
    if click.confirm(f'Are you sure you want to confirm {user!r}?'):
        if security_service.confirm_user(user):
            click.echo(f'Successfully confirmed {user!r} at '
                       f'{user.confirmed_at.strftime("%Y-%m-%d %H:%M:%S%z")}')
            user_manager.save(user, commit=True)
        else:
            click.echo(f'{user!r} has already been confirmed.')
    else:
        click.echo('Cancelled.')