
8 Cal.Rptr.3d 238 (2004)
114 Cal.App.4th 1095
The PEOPLE, Plaintiff and Respondent,
v.
Jon Vincent JUAREZ, Defendant and Appellant;
In re Jon Vincent Juarez on Habeas Corpus.
Nos. A101227, A102470.
Court of Appeal, First District, Division Two.
January 7, 2004.
*239 Parker S. Kelly, Redwood City, Robert Faux, Santa Rosa, under appointment by the Court of Appeal, for Defendant and Appellant.
Bill Lockyer, Attorney General of the State of California, Robert R. Anderson, Chief Assistant Attorney General, Gerald A. Engler, Senior Assistant Attorney General, Stan M. Helfman, Supervising Deputy Attorney General, Ayana A. Cuevas, Deputy Attorney General, for Plaintiff and Respondent.
LAMBDEN, J.
Appellant appeals from his sentence to a term of probation conditioned upon his waiver of all credits for time served. The trial court's order suspended a maximum sentence to state prison and required appellant to participate in a residential drug treatment program. Appellant contends that the time he may spend incarcerated will exceed the maximum permitted by statute. Appellant's court-appointed counsel has asked us to review the record of the conviction pursuant to People v. Wende (1979) 25 Cal.3d 436, 158 Cal.Rptr. 839, 600 P.2d 1071, and filed a petition for writ of habeas corpus, which we ordered to be considered with the appeal. At our request, both sides filed supplemental briefs regarding the propriety of the sentence ordered by the trial court. We affirm.

INTRODUCTION
This case illustrates an anomaly which persists in the wake of the Supreme Court's opinion in People v. Johnson (2002) 28 Cal.4th 1050, 123 Cal.Rptr.2d 700, 51 P.3d 913 (Johnson II), which discussed the circumstances under which a trial court can require a defendant to waive credits for time served, on top of a maximum sentence, in order to obtain probation. The Supreme Court upheld the discretion of the trial court to impose such a sentence in Johnson II and suggested that a defendant might not have any basis to challenge such a sentence until the maximum statutory sentence is served. The Supreme Court declined to discuss a split of appellate authority over whether trial courts can routinely require waiver of time credits beyond the statutory term in maximum-sentence cases. Arguably, there remains some ambiguity regarding when a defendant can challenge a sentence that is combined with the waiver of time-served credits and thereby exceeds the statutory maximum.

BACKGROUND
Appellant was charged with two counts of entering an inhabited dwelling with intent to commit larceny, in violation of Penal Code section 459 (all further unspecified code sections refer to the Penal Code). He pleaded no contest to a single count of larceny and was sentenced to a term of 24 months probation under standard conditions, including the requirement that he serve six months in the county jail and participate in a residential drug treatment program.
Seven months later, appellant's probation was revoked; and he subsequently admitted that he had violated the terms of his probation. After subjecting appellant to a 90-day diagnostic study pursuant to section 1203.03, the trial court sentenced appellant to the statutory maximum of three years in state prison, and suspended the sentence. The court reinstated appellant's probation with new conditions, including another eight months in the county jail and further residential drug treatment. To obtain this result, appellant was required to waive all credit for the time he had served, and would serve, in the treatment program and in county jail.
*240 At the sentencing hearing, appellant agreed to the terms of this sentence pursuant to People v. Johnson (1978) 82 Cal.App.3d 183, 147 Cal.Rptr. 55 (Johnson I). He thus expressly waived all credits for the time he had previously served in jail and all credits for the time he had spent in the residential treatment program. It is undisputed that the probation department's report calculated his total credit for time served in both venues to have totaled 392 days. At the sentencing hearing, defense counsel objected to the waiver of time-served credits and the court noted the preservation of the issue for appeal. Appellant's notice of appeal and petition for writ of habeas corpus contend that the court committed error by requiring appellant to "waive all previously accrued credits in order to have probation reinstated...."

DISCUSSION
The underlying facts pertaining to appellant's offense are immaterial to our discussion of the claimed sentencing error. Turning first to our examination of the record pursuant to People v. Wende, supra, 25 Cal.3d 436, 158 Cal.Rptr. 839, 600 P.2d 1071, we discern no issues requiring further briefing or discussion, other than those discussed below in connection with the alleged sentencing error. We consider the circumstances where a trial court can require waiver of statutorily mandated time-served credits when the result may be a sentence exceeding the maximum sentence provided by law. We also revisit the issue of whether a trial court is permitted to routinely require the waiver of such credits, without any case specific exercise of discretion.
Appellant first contends that the sentence imposed by the trial court was illegal. At the sentencing hearing, defense counsel objected to the proposed waiver of appellant's previous time credits because it could potentially expose appellant to a total term in excess of the three-year maximum term provided for the offense. Counsel cited the opinion in People v. Tran (2000) 78 Cal.App.4th 383, 92 Cal.Rptr.2d 815 (Tran) in support of this argument; but the court seemed unfamiliar with the case. However, in response to the court's suggestion that the sentencing could be continued for briefing of the issue, defense counsel responded that his client wished only to preserve the objection and to proceed with sentencing. In response to questioning by the court, appellant agreed to give up 392 days of time-served credit by entering a "Johnson waiver" (Johnson I, supra, 82 Cal.App.3d 183, 147 Cal.Rptr. 55). The "Johnson waiver" was explained to appellant to be his agreement that he would be willing to spend more than a year in county jail.
Tran distinguished a similar waiver of custody credits from prior authority permitting such waivers in a variety of circumstances. (See Johnson I, supra, 82 Cal.App.3d 183, 147 Cal.Rptr. 55; People v. Ambrose (1992) 7 Cal.App.4th 1917, 9 Cal.Rptr.2d 812 (Ambrose); People v. Salazar (1994) 29 Cal.App.4th 1550, 35 Cal.Rptr.2d 221; and People v. Burks (1998) 66 Cal.App.4th 232, 77 Cal.Rptr.2d 698.) The record in Tran did not contain evidence that the required waiver would have any effect on the appellant's attitude towards the completion of the residential treatment program contemplated by the sentence. The Tran opinion concluded that it was unlikely that any remand for reconsideration of the sentence of probation could result in the development of further facts; and, out of concern that the defendant could be effectively penalized for his appeal if probation were reconsidered, the trial court was ordered to remove *241 the condition requiring waiver of custody credits.
In its 2002 opinion (in Johnson II, supra, 28 Cal.4th 1050, at pp. 1056-1057, 123 Cal.Rptr.2d 700, 51 P.3d 913), the Supreme Court disapproved of any reading of Tran suggesting that such a waiver of time credits is never permitted where the suspended sentence to state prison is for the maximum term. The Supreme Court focused on the sentencing discretion reserved to the trial court and observed that waivers of custody credits under section 2900.5[1] have been upheld in a variety of circumstances that did not involve maximum sentences. (See People v. Torres (1997) 52 Cal.App.4th 771, 775, 60 Cal.Rptr.2d 803 [waiver at sentencing of future credits for probationary term in drug treatment program presumed to be reasonable if it bears any relationship to the offense]; People v. Salazar, supra, 29 Cal.App.4th at pp. 1553-1556, 35 Cal.Rptr.2d 221 [waiver at reinstatement of probation of past custody credits]; Ambrose, supra, 7 Cal.App.4th at pp. 1920, 1925, 9 Cal.Rptr.2d 812 [refusal to overturn probation condition requiring waiver of past and future credits at reinstatement of probation]; People v. Zuniga (1980) 108 Cal.App.3d 739, 743, 166 Cal.Rptr. 549 [waiver at sentencing of past custody credits].) Indeed, the Tran opinion itself acknowledged that defendants could waive custody credits in situations where the record suggests a factual basis for the court's exercise of its discretion. (Tran, supra, 78 Cal.App.4th at pp. 387-388, 92 Cal.Rptr.2d 815.)
We take our direction from Johnson II (see Auto Equity Sales, Inc. v. Superior Court (1962) 57 Cal.2d 450, 455, 20 Cal.Rptr. 321, 369 P.2d 937) which held that a trial court may exercise its discretion to conclude that a waiver of custody credits, in addition to the threat of a maximum prison term, may be necessary to provide a defendant with "sufficient incentive to comply with the other terms of probation and to successfully complete the rehabilitation program." (Johnson II, supra, 28 Cal.4th at p. 1057, 123 Cal.Rptr.2d 700, 51 P.3d 913.) To reach this conclusion, the Supreme Court concluded that "In general, defendants may waive provisions that are intended for their benefit, and the provision of section 2900.5 allowing defendants to receive credits against an eventual sentence for time spent in custody before sentencing or while on probation is intended to benefit defendants, as we explained at pages 1054-1055, 123 Cal.Rptr.2d 700, 51 P.3d 913, ante." (Johnson II, supra, at p. 1057, 123 Cal.Rptr.2d 700, 51 P.3d 913.)
Johnson II distinguished Ambrose, which had permitted the waiver of future credits but also suggested that a defendant must be released upon completion of the maximum statutory term, as follows: "`This does not mean, of course, that we would endorse a situation in which the denial of future credit enabled the court to impose a term which is longer than the maximum allowable for the offense. Even if a defendant agrees to such a negotiated disposition, a trial court should not impose a sentence in excess of the maximum allowable for the plea entered.... (Ambrose, supra, at p.1924.... [9 Cal.Rptr.2d 812])'" (Johnson II, supra, 28 Cal.4th at pp. 1056-1057, 123 Cal.Rptr.2d 700, 51 *242 P.3d 913.) The opinion in Johnson II concluded that the holding in Ambrose was limited to the circumstance where the term of custodial treatment was indefinite and also noted that permitting such waivers to facilitate treatment is consistent with both federal law and the general rule provided by statute. (See United States v. Mezzanatto (1995) 513 U.S. 196, 201, 115 S.Ct. 797, 130 L.Ed.2d 697; and Civ.Code, § 3513.) (Johnson II, supra, at p. 1055, 123 Cal.Rptr.2d 700, 51 P.3d 913.)
The Johnson II opinion thus disagreed with the defendant's contention that requiring him to waive all custody credits to obtain probation served no legitimate purpose other than to increase his maximum term of incarceration if he failed on probation. Rejecting this argument, the Supreme Court emphasized the trial court's sentencing discretion: "Exercising its discretion, the trial court determined that imposing the maximum term for defendant's crime of residential burglary and conditioning probation on a waiver of section 2900.5 custody credits was necessary to provide defendant with sufficient incentive to comply with the other terms of probation and to successfully complete the rehabilitation program." (Johnson II, supra, 28 Cal.4th at p. 1057, 123 Cal.Rptr.2d 700, 51 P.3d 913.)
However, the penultimate sentence of the Johnson II opinion left open the possibility that a sentence exceeding the statutory maximum by reason of waived time-credits might still be challenged. The Supreme Court stated that the defendant in Johnson II "[made] no claim that, as a result of the waiver condition, the total time he will be required to spend in custody ... will exceed the maximum term statutorily authorized for the crime he committed." (Johnson II, supra, 28 Cal.4th at pp. 1057-1058, 123 Cal.Rptr.2d 700, 51 P.3d 913.) Based on this failure to show that the sentence would actually exceed the legal maximum, as well as the conclusion that such waivers are allowed where they are shown to serve a purpose, the opinion concluded that "[u]nder these circumstances, we conclude that defendant has failed to show that the custody credit waiver condition was invalid, and we further conclude that the state prison sentence the court imposed, for the maximum term authorized by law, was a valid sentence and was not rendered unlawful by defendant's waiver of custody credits." (Id. at p. 1058, 123 Cal.Rptr.2d 700, 51 P.3d 913.)
One conclusion that might be drawn from the last paragraph of the Johnson II opinion is that appellant may not appeal from a sentence that potentially exceeds the statutory maximum until it can be proven that the time served will exceed the term authorized by law. Presumably this would occur when the maximum sentence is served. We reject this conclusion not only because of its implication that later proceedings could be required, but also because the Supreme Court's opinion in Johnson II did not retreat from its prior holding (in People v. Welch (1993) 5 Cal.4th 228, 236-237, 19 Cal.Rptr.2d 520, 851 P.2d 802) that an objection at the time of sentencing suffices to preserve for appeal the question of waiver of time credits as a condition of probation. Requiring a defendant to serve the statutory maximum sentence before filing a petition to modify the sentence by reinstating time-served credits would be procedurally clumsy.
The reasoning of the Johnson II opinion, with its repeated emphasis on the discretion reserved to the trial court, suggests a better approach: the "circumstances" under which the court found that the defendant had "failed to show that the custody credit waiver condition was invalid" included not only the fact that he had *243 not yet served a maximum sentence, but also the fact that the trial court, "[e]xercising its discretion," had determined that the waiver was "necessary to provide defendant with sufficient incentive to comply with the other terms of probation...." (Johnson II, supra, 28 Cal.4th at pp. 1057-1058, 123 Cal.Rptr.2d 700, 51 P.3d 913.) The Supreme Court's reasoning in 2002 thus reminds us of the logic of the Johnson I opinion in 1978, which originally permitted the waiver of statutory time-served credits in order to avoid limitations upon the trial court's discretion to craft "appropriate" probation conditions that might benefit the defendant. If the appellant's agreement to waive his time-served credits to avoid state prison and to obtain further drug treatment were the only issue presented here, and the trial court had cited the foregoing precedents, we might presume that the imposition of the waiver condition was an exercise of discretion; and the resulting order might be impervious to appellate challenge. (Ambrose, supra, 7 Cal.App.4th at p.1925, 9 Cal.Rptr.2d 812.)
It is well settled that "[t]rial courts are granted broad discretion under ... section 1203.1 to prescribe conditions of probation." (People v. Richards (1976) 17 Cal.3d 614, 619, 131 Cal.Rptr. 537, 552 P.2d 97, disapproved on other grounds in People v. Carbajal (1995) 10 Cal.4th 1114, 1126, 43 Cal.Rptr.2d 681, 899 P.2d 67; see also People v. Pointer (1984) 151 Cal.App.3d 1128, 1136, 199 Cal.Rptr. 357.) Even so, a ruling otherwise within the trial court's power will be set aside where it appears from the record that the court actually failed to exercise the discretion vested in it by law. (People v. Beasley (1970) 5 Cal.App.3d 617, 633-634, 85 Cal.Rptr. 501; People v. Wallace (1963) 59 Cal.2d 548, 553, 30 Cal.Rptr. 449, 381 P.2d 185; In re Brumback (1956) 46 Cal.2d 810, 813, 299 P.2d 217; see People v. Ruby (1988) 204 Cal.App.3d 462, 466-468, 251 Cal.Rptr. 339, review den.; People v. Jasper (1983) 33 Cal.3d 931, 935, 191 Cal.Rptr. 648, 663 P.2d 206.) However, the exercise of such discretion must be demonstrated on the record; and appellant contends that the trial court did not do so.
This brings us to the second question presented by this appeal: can a trial court routinely, and without any case specific exercise of discretion, require waivers of time-credits as a "standard" condition of probation where the suspended sentence is for the maximum term? Appellant contends the court employed such a practice in this case.
The opinion in Johnson II did not discuss the split of appellate authority regarding the exercise of discretion where it is claimed that the trial court routinely requires such waivers in all similar cases. The Supreme Court merely remarked in a footnote that "[w]e do not here consider whether a trial court could within the proper exercise of its discretion routinely condition grants of probation upon waivers of credit for time served." (Johnson II, supra, 28 Cal.4th p. 1055, fn. 3, 123 Cal.Rptr.2d 700, 51 P.3d 913.)
People v. Penoli (1996) 46 Cal.App.4th 298, 53 Cal.Rptr.2d 825 (Penoli) held that the trial court erroneously failed to exercise discretion when it routinely employed the "standard practice'" of requiring defendants to waive all custody time-credits in order to enter drug rehabilitation programs. Penoli reasoned that this sort of "standard" condition represented a preconceived determination applicable to all cases in which the question might arise, and that the court's adherence to such a practice was a systematic failure to exercise the necessarily case-specific application of sentencing discretion vested in the court by law. (Id. at pp. 303-304, 53 Cal.Rptr.2d 825; see also People v. Jasper, *244 supra, 33 Cal.3d at p. 935, 191 Cal.Rptr. 648, 663 P.2d 206 [if trial court had "`routine practice'" as to discretionary scheduling matter, it was improper]; Mark F. v. Superior Court (1987) 189 Cal.App.3d 206, 210-212, 234 Cal.Rptr. 388, review den. [probation department abused discretion by applying inflexible policy of denying probation to juveniles charged with drunk driving]; cf. People v. Preyer (1985) 164 Cal.App.3d 568, 574, 210 Cal.Rptr. 807 [discretionary ruling must be assessed on particular facts of case, not statistics]; People v. Hodgkin (1987) 194 Cal.App.3d 795, 810-811, 239 Cal.Rptr. 831 [sentence remanded for "particularized inquiry" into defendant's ability to comply with conditions].)
In People v. Torres, supra, 52 Cal.App.4th 771, 60 Cal.Rptr.2d 803 (Torres), another appellate panel concluded that "the proper test for evaluating a condition of probation imposed by a trial court, as a standard practice or otherwise, is simply whether the condition bears a reasonable relationship to the offense and the offender. If there is such a reasonable relationship, the trial court has not abused its discretion." (Id. at p. 782, 60 Cal.Rptr.2d 803.) The Torres court did not acknowledge the problem presented where a presumably reasonable waiver of time credits results in a sentence that exceeds the maximum allowed by statute. The Torres opinion essentially discounted the application of section 2900.5 and concluded that such waivers are justified for the same reason given by the trial court which was reversed in Penoli: because "no public purpose is served by crediting custody time to a probationer who fails drug program rehabilitation...." (Id. at p. 778, 60 Cal.Rptr.2d 803.)
In Penoli, the trial court explained its "practice" by stating that its reasons for denying credit were "`better than the Legislature's reasons'" for allowing credit. (Penoli, supra, 46 Cal.App.4th at p. 304, 53 Cal.Rptr.2d 825.) The Penoli opinion observed that the discretion granted sentencing courts must be exercised with a view toward effectuating, not frustrating, legislative policy. (Ibid.; see People v. Ortiz (1964) 61 Cal.2d 249, 254-255, 37 Cal.Rptr. 891, 391 P.2d 163; People v. Ruby, supra, 204 Cal.App.3d at p. 468, 251 Cal.Rptr. 339.) A sentencing determination predicated on the judicial repudiation of legislative policy constitutes an abuse of discretion. (People v. Dent (1995) 38 Cal.App.4th 1726, 1731, 45 Cal.Rptr.2d 746 [discretionary sentencing determination "can be properly made only when the sentencing court focuses on considerations that are pertinent to the specific defendant being sentenced, not an aversion to a particular statutory scheme"].) Although the trial court here did not state any such disagreement with the statutory scheme, we conclude that the probation condition challenged by appellant must necessarily fall within the same rule of deference to the legislative policies described by statute.
Accordingly, while the Supreme Court has not yet addressed the question of whether a trial court can make it a "standard practice" to increase maximum statutory sentences by requiring defendants to waive the time credits mandated by section 2900.5, the reasoning consistently employed by all the prior precedents suggests that such waivers will be permitted only in the context of an exercise of sentencing discretion. The opinion in Tran modified a sentence based on an aggravated term and waivers of time-served credits, which together exceeded the maximum term provided by law, because the record disclosed no apparent reason for the increased sentence other than to increase the potential punishment of the defendant. Johnson II, supra, 28 Cal.4th at pp. 1055, 1057, 123 Cal.Rptr.2d 700, 51 P.3d 913) only disapproved of any reading of Tran that would draw a bright line to suggest there can *245 never be a waiver of time credits in a maximum sentence case. And Johnson II focused on the trial court's exercise of discretion as the means to provide defendants with "sufficient incentive to comply with the other terms of probation." (Id. at p. 1057, 123 Cal.Rptr.2d 700, 51 P.3d 913.)
The logic that thus unites all the precedents is founded upon the need to preserve the discretion of the trial courts to craft appropriate sentences, which are also legally sound. This conclusion follows naturally from the original reasoning of the Johnson I opinion which observed that the confluence of section 19.2 (providing that a defendant could not be sentenced to jail for more than a year) and section 2900.5 (requiring credit for all days in custody) would, if read literally, leave a trial court considering a modification of probation with no choice of incentives other than to send the defendant to state prison. The Johnson I court concluded that the proper interpretation of section 2900.5 permits a defendant to knowingly and intelligently waive the provisions of that section in order to permit the court to "fashion an intermediate disposition by modifying probation to provide for additional time up to one year in jail." (Johnson I, supra, 82 Cal.App.3d at p. 188, 147 Cal.Rptr. 55.) Later opinions have expanded upon this view; and as discussed above, where a reason is shown to support the requirement for such a waiver, it is not disputed that it may be employed.
We conclude that the reasoning of the Supreme Court's opinion in Johnson II is incompatible with the idea that a waiver of credits for time served can be routinely required without any discrete exercise of discretion. The split of authority created by the Torres decision thus has been implicitly resolved. The proposal by Torres that a waiver of time credits may be imposed "routinely or otherwise" as a condition of probation whenever the condition bears any "reasonable relationship to the offense and the offender" (Torres, supra, 52 Cal.App.4th at p. 782, 60 Cal.Rptr.2d 803 is inconsistent with the Supreme Court's emphasis on the exercise of sentencing discretion. The desirability of preserving such discretion was the principal reason for permitting such waivers in the first place (Johnson I, supra, 82 Cal.App.3d 183, 147 Cal.Rptr. 55) and this policy was plainly reiterated by the Supreme Court in Johnson II.
The reason for this conclusion is evident. As has been previously observed, the presumption that waivers of the time credits mandated by section 2900.5 can be routinely required, without any discrete exercise of discretion and as a "standard practice," would function as the judicial extension of the maximum sentences fixed by the Legislature. The exception to the statutory proscriptions is based solely upon the discretion necessarily reserved to the trial courts for policy reasons; and the Supreme Court has not modified the rule allowing appeals to be taken from the trial courts' exercise of such discretion by accepting waivers of time credits in order to craft appropriate conditions of probation (People v. Welch, supra, 5 Cal.4th at pp. 236-237, 19 Cal.Rptr.2d 520, 851 P.2d 802). The Supreme Court must have had these circumstances in mind when it held that a trial court could exercise its discretion to employ such waivers in order to provide "sufficient incentive to comply with the other terms of probation and to successfully complete the rehabilitation program" (Johnson II, supra, 28 Cal.4th at p. 1057, 123 Cal.Rptr.2d 700, 51 P.3d 913).
We therefore feel comfortable in concluding that the holding in Penoli remains viable: the standard practice of requiring a defendant to waive custody time credit in order to obtain certain conditions of probation is not allowed where the court fails to exercise any sentencing discretion *246 regarding such a waiver (Penoli, supra, 46 Cal.App.4th at pp. 303-304, 53 Cal.Rptr.2d 825). The opinion in Johnson II supported this conclusion by finding that there was evidence to support the requirement of the waiver of time credits in that case (Johnson II, supra, 28 Cal.4th 1050, 123 Cal.Rptr.2d 700, 51 P.3d 913). The Supreme Court's emphasis upon the trial court's exercise of sentencing discretion did not employ the presumption of reasonableness proposed in Torres supra, 52 Cal.App.4th 771, 60 Cal.Rptr.2d 803, and did not endorse the Torres court's ipse dixit statement that "no public purpose is served by crediting custody time to a probationer who fails drug program rehabilitation...." (Id. at p. 778, 60 Cal.Rptr.2d 803.) Although the Supreme Court's opinion offered no comment on the application of such preconceptions, it also did not employ reasoning consistent with such an approach. Rather, the Supreme Court examined the record to determine whether the trial court had exercised its discretion to provide incentives to comply with the terms of probation as part of the "legitimate penal function" of the sentence. (Johnson II, supra, at p. 1057, 123 Cal.Rptr.2d 700, 51 P.3d 913.) We have used the same analysis here.
We are not persuaded by appellant's attempt to show that the trial court failed to exercise its discretion with regard to the waiver of time-served credits. The declaration of counsel filed with appellant's petition for writ of habeas corpus claims "firsthand knowledge" of no less than 400 cases in this particular judge's court where similar waivers of time-served credits were required. The declaration states in conclusory fashion that "[i]t is the standard practice in Judge['s] court that defendants must waive all custody credits for time prospectively to be spent in [residential drug] programs." Notwithstanding these statements, our examination of the record leads us to conclude that the court did not require waiver of time credits based merely on routine practice. Rather, the court exercised its discretion.
At the time of sentencing, the trial court had already taken the additional step of sending appellant for a diagnostic review by the Department of Corrections and the court remarked that it thought appellant "gained something from that experience." When defense counsel raised the question of whether a maximum sentence could be imposed on top of a waiver of all custody credits, the prosecutor proposed that the matter was still negotiable. The trial court was willing to continue the matter for further briefing and negotiation, but the defendant wanted to proceed. The court discussed, in detail, the various reports and facts contained in the probation file; and the court expressed the desirability of imposing particular probation conditions to help appellant "get off" drugs, complete a rehabilitation program and avoid prison. In its entirety, the record demonstrates that the trial judge was fully acquainted with appellant's case and made an informed decision to require the waiver of custody credits as a further incentive to complete his rehabilitation, and to thus avoid serving the aggravated term in state prison. Accordingly, we conclude that the trial court properly exercised its discretion, and did not require the waiver of time-served credits as part of any preconceived, standard practice. The sentence was therefore permissible.

DISPOSITION
The sentencing order is affirmed. The petition for writ of habeas corpus is denied.
We concur: KLINE, P.J., and HAERLE, J.
NOTES
[1]  "In all felony and misdemeanor convictions, ... when the defendant has been in custody, including, but not limited to, any time spent in a ... rehabilitation facility ... or similar residential institution, ... all days of custody of the defendant, including days served as a condition of probation in compliance with a court order, and including days credited to the period of confinement pursuant to Section 4019, shall be credited upon his or her term of imprisonment...." (§ 2900.5, subd. (a).)
