If any person confined in the penitentiary, in a county workhouse, a city or county jail or any other penal institution, upon any charge of or conviction of any criminal offense, by any means or method willfully inflicts any wound upon such inmate's own person for the purpose of or with the effect of rendering the inmate unfit for or incapable of performing any labor assigned, the inmate may be confined in solitary confinement or subject to such other punishment, not inconsistent with humanity, as may be deemed necessary by the warden, sheriff or commissioners for the government and control of the inmates. Inmates who are placed in solitary confinement or who are hospitalized as a result of any self-inflicted wounds shall receive no credit for the time so spent.