
78 Cal.App.3d 712 (1978)
144 Cal. Rptr. 326
In re DANIEL FERNAND CHAMBERLAIN on Habeas Corpus.
Docket No. 31071.
Court of Appeals of California, Second District, Division Four.
March 15, 1978.
*715 COUNSEL
Paul Halvonik, State Public Defender, under appointment by the Court of Appeal, Charles M. Sevilla, Chief Assistant State Public Defender, and Edward H. Schulman, Deputy State Public Defender, for Petitioner.
Evelle J. Younger, Attorney General, Jack R. Winkler, Chief Assistant Attorney General, S. Clark Moore, Assistant Attorney General, Shunji Asari and John A. Saurenman, Deputy Attorneys General, for Respondent.
OPINION
FILES, P.J.
In this habeas corpus proceeding petitioner seeks a modification of the terms of his probation so as to give him credit for presentence custody pursuant to Penal Code section 2900.5.
The facts are not in dispute. On March 11, 1977, an information was filed charging petitioner with assault with a deadly weapon upon a peace officer, a violation of Penal Code section 245, subdivision (b). Under the law then applicable, the punishment for that offense was imprisonment in the state prison for six months to life.
*716 On March 14, 1977, petitioner pleaded guilty before Judge Stevens. Before receiving the plea the court stated "[T]he only promise that I am making is when this matter comes back before the Court for sentencing, at that time this Court will not send you to the State Prison but will use some other form of sentence."
On April 7 petitioner was placed at a diagnostic facility of the Department of Corrections for diagnosis and recommendation.
On July 8 petitioner appeared before Judge Donnellan for sentencing. Upon arraigning petitioner, the court pointed out that both the probation report and the Department of Corrections had recommended a state prison sentence, but "the so-called plea bargain was that there be no state prison." The court then discussed with counsel the reports indicating that defendant's violent behavior was caused by alcohol, that hospitalization might be beneficial if accepted on a voluntary basis, and that unless petitioner was treated successfully, he posed a serious threat to the community. The court also commented on the fact that under Penal Code section 2900.5 petitioner would be entitled to credit for presentence confinement, which counsel estimated to be four months.[1]
*717 The court then made this proposal: "If I were to put him on probation on condition he serve time in the county jail, I can't exceed one year under the law. In my opinion, he needs at least one year for alcoholism treatment at a county jail facility.... I could give him a year, but I'd have to give him credit for all time in custody to date; .... With that in mind I will place the defendant on probation on condition he serve one year in the county jail; no credit allowed, and if he seeks credit and if a District Court of Appeals states that I must give him credit, then in that case I don't intend this sentence. In that case the sentence should be state prison, and if he doesn't want state prison, I'll set aside the plea; so what's he wish to do?"
Following a conference between petitioner and his counsel, the latter stated: "Your honor, Mr. Chamberlain indicates he's thought it over and he's willing to take probation with the year in the county jail as the court indicated."
The court then sentenced petitioner to state prison for the term prescribed by law, execution was suspended, and petitioner placed on probation for a period of three years, subject to several conditions, including the following: "First, he is to serve one year in the county jail. Mira Loma is recommended. No credit is to be allowed for time in custody to date. No parole to be afforded the defendant. Good time and work time to be allowed if earned."
Approximately one month later petitioner filed his handprinted petition in this court demanding that he receive 140 days credit for presentence custody, citing Penal Code section 2900.5.
We appointed the State Public Defender to represent petitioner in this court. Counsel has filed a supplemental petition containing the relevant documents and transcripts and an argument for petitioner's contention that he was entitled to 140 days credit.
(1) It was improper for the judge who took the plea to promise that petitioner would not be sent to prison. (See People v. Johnson (1974) 10 Cal.3d 868, 871 [112 Cal. Rptr. 556, 519 P.2d 604].) The judge had no authority at that stage of the case to make such a promise. (See People v. *718 Beasley (1970) 5 Cal. App.3d 617, 633 [85 Cal. Rptr. 501].) The proper procedure for taking a negotiated plea is set forth in Penal Code section 1192.5.
However, it now appears that that error may be disregarded. The trial court offered petitioner an opportunity to withdraw his plea, which he declined. In this court, through his counsel, petitioner states unequivocally that he "does not wish to rescind his plea bargain." He is asking the court to order credit for presentence confinement, but if given a choice between a rescission of his plea and probation under the terms prescribed on July 8, 1977, he will accept the latter.
The issues to be resolved require an interpretation of the second sentence of subdivision (c) of Penal Code section 2900.5, which states: "The credits provided by this section shall not be considered in establishing or fixing any condition of probation, parole date, or term of imprisonment; but such credits shall be applied to any such condition of probation, parole date, or term of imprisonment no later than one week after it has been established or fixed."
(2) The evident purpose of section 2900.5 is to afford a kind of equity for persons who have served time in custody prior to the sentence. Obviously, the statute cannot afford exact equality, because the various kinds of confinement for which credit is given are by no means equal  either in the conditions of imprisonment or in their effect. Nevertheless the Legislature has mandated a kind of equality of time, and in so doing has limited the discretion of the trial court to make its own ad hoc adjustment to fit what it perceives as equity and justice.
(3) The requirement that "the credits provided by this section shall not be considered" forbids a court to evade the statutory purpose of time-equality by adjusting the length of the sentence or the probationary term upward to cancel out the credit.
But we cannot read that statutory language as meaning that the sentencing judge shall act in ignorance of the credits. Subdivision (d) of section 2900.5 requires the sentencing court to determine the amount of the credit and enter it in the abstract judgment. Rule 252, California Rules of Court, directs the probation officer to report the number of days of credit to which a defendant may be entitled, provides for an *719 opportunity to challenge that report, and requires the court to find and record in the judgment or commitment the time to be credited.
(4) In the present case the court believed, upon the basis of the information in the record, that the only appropriate alternative to a state prison sentence in this case was a full year's treatment for alcoholism in a local facility. We cannot construe the "not to be considered" language in section 2900.5 as requiring the judge to pretend that a year's commitment, less 140 days credit, would afford a year of treatment. The effect of the credit was a fact which could not be ignored.
The court was also aware that Penal Code section 19a placed a one-year limit upon a county jail commitment given as a condition of probation. In this situation, the court's alternatives were constrained by the statutory limitations of sections 19a and 2900.5, and by the court's own belief as to the treatment which petitioner required. The only disposition within those restraints would have been a state prison term.
(5) The remaining question is whether in this proceeding, which is a collateral attack upon the judgment, petitioner is entitled to the relief he seeks.
Petitioner does not deny that he accepted the trial court's terms of probation advisedly, in his own best interest. He does not contend, and he has no basis for contending, that the conditions of probation were inappropriate or unreasonable in any respect. He does not ask us to set aside the order granting probation. He is asking only a change in the terms of probation, which may thwart the therapeutic purpose of the trial court.
In re Handsome (1977) 72 Cal. App.3d 657 [138 Cal. Rptr. 400], involved two petitioners, each of whom had entered into a "plea bargain" in 1977 which called for probation and a year in county jail without credit for prior time in custody. Each petitioned the appellate court for an order compelling a credit for "back time." The appellate court concluded at page 660 "Since neither desires to rescind his plea bargain and stand trial on the informations filed against them, their petitions must be denied."
The present case involves not an arrangement made as a condition of a plea, but a term agreed upon as a condition of probation. In this case, as in Handsome, the petitioner seeks to preserve what he likes of the prior *720 disposition and change what he doesn't like. As in Handsome, petitioner is not entitled to relief on those terms.
The petition is denied.
Kingsley, J., concurred.
JEFFERSON (Bernard), J.
I concur in the result reached by the majority but I am not satisfied with the reasoning by which the result is reached.
Neither the majority's opinion nor the decision of In re Handsome (1977) 72 Cal. App.3d 657 [138 Cal. Rptr. 400], cited by the majority, satisfactorily explains how a trial judge may impose, as a condition of probation, a sentence that defendant serve one year in the county jail with no credit to be allowed for time spent in custody. Such a condition of probation appears to be in direct conflict with, and a violation of, the mandates of Penal Code section 19a, which places a one-year limit upon a county jail commitment given as a condition of probation, and of Penal Code section 2900.5, subdivision (c), which provides, in relevant part, that "such credits shall be applied to any such condition of probation." (Italics added.)
It is not sufficient to reason that a defendant simply cannot seek to hold on to that part of his plea bargain which is a nonprison term but evade that part of his plea bargain which provides that no credit shall be allowed for his days in custody. This reasoning does not make legal what is otherwise an illegal sentence. The reasoning of the majority in the instant case and of the Handsome court should lead to the result that the trial court's sentence should be vacated as an illegal sentence, irrespective of a defendant's desires.
I reach the same result as the majority and the Handsome court by interpreting Penal Code section 2900.5 as permitting a defendant to knowingly and intelligently waive the provisions thereof that require all days of custody to be credited to his sentence, including any period of imprisonment as a condition of probation. In the case at bench, we have such a knowing and intelligent waiver by the defendant. *721 But in the absence of Penal Code section 2900.5 being interpreted to permit a waiver by defendant of his right to credit for days spent in custody prior to sentence, I am unable to justify, as valid, any sentence of imprisonment  whether imposed as a condition of probation or not  which eliminates the credit for days in custody. In the absence of an appropriate waiver by a defendant, any such sentence should be declared illegal and ordered vacated.
NOTES
[1]  Penal Code section 2900.5, as amended, effective January 1, 1977, provides:

"(a) In all felony and misdemeanor convictions, either by plea or by verdict, when the defendant has been in custody, including but not limited to any time spent in a jail, camp, work furlough facility, halfway house, rehabilitation facility, hospital, prison, or similar institution, all days of custody of the defendant, including days served as a condition of probation in compliance with a court order, shall be credited upon his sentence, or credited to any fine which may be imposed, at the rate of not less than thirty dollars ($30) per day, or more, in the discretion of the court imposing the sentence. If the total number of days in custody exceeds the number of days of the sentence to be imposed, the entire sentence shall be deemed to have been served. In any case where the court has imposed both a prison or jail sentence and a fine, any days to be credited to the defendant shall first be applied to the sentence imposed, and thereafter such remaining days, if any, shall be applied to the fine.
"(b) For the purposes of this section, credit shall be given only where the custody to be credited is attributable to proceedings related to the same conduct for which the defendant has been convicted.
"(c) For the purposes of this section, `sentence' includes any fine or period of imprisonment imposed as a condition of probation or otherwise ordered by a court in imposing or suspending the imposition of any sentence, and also includes any term of imprisonment, including any period of imprisonment prior to release on parole and any period of imprisonment and parole, prior to discharge, whether established or fixed by statute, by any court, or by any duly authorized administrative agency. The credits provided by this section shall not be considered in establishing or fixing any condition of probation, parole date, or term of imprisonment; but such credits shall be applied to any such condition of probation, parole date, or term of imprisonment no later than one week after it has been established or fixed.
"(d) It shall be the duty of the court imposing the sentence to determine the total number of days to be credited pursuant to the provisions of this section. The total number of days to be credited shall be contained in the abstract of judgment provided for in Section 1213."
