(b) (1) If the person has been convicted previously of an infraction under subdivision (a) or has a prior conviction of Section 594, 594.3, 594.4, 640.5, or 640.7, the offense is a misdemeanor, punishable by a period not to exceed six months in a county jail, by a fine not to exceed $2,000, or by both that imprisonment and fine.