This section applies where—
a court has power, by virtue of any enactment, to deal with a person for an offence in any way in which—
a court could have dealt with the person on a previous occasion, or
a court could deal with the person if the person were the same age as when convicted,
in exercise of the power, the court makes a detention and training order for any term, and
the person has reached the age of 18.
The person is to be treated as if sentenced to detention in a young offender institution for the same term.