Whenever any person licensed under this code is convicted of a violation of any provision of this code relating to the speed of vehicles or a violation of Section 23103 the court may, unless this code makes mandatory a revocation by the department, suspend the privilege of the person to operate a motor vehicle for a period of not to exceed 30 days upon a first conviction, for a period of not to exceed 60 days upon a second conviction, and for a period of not to exceed six months upon a third or any subsequent conviction.