In any case in which a person is confined to a city or county jail for a definite period of time for contempt pursuant to an action or proceeding other than a criminal action or proceeding, all of the provisions of law authorizing, requiring, or otherwise relating to, the performance of labor or work by persons sentenced to such facilities for like periods of time under a judgment of imprisonment, or a fine and imprisonment until the fine is paid or as a condition of probation after suspension of imposition of a sentence or suspension of execution of sentence, in a criminal action or proceeding, shall apply.
Nothing in this section shall be construed to authorize the confinement of any prisoner contrary to the provisions of Section 4001.
Ca. Pen. Code § 4017.5