
139 Cal.App.3d 620 (1983)
188 Cal. Rptr. 846
THE PEOPLE, Plaintiff and Respondent,
v.
JAMES EARL RUTLEDGE, Defendant and Appellant.
Docket No. 5954.
Court of Appeals of California, Fifth District.
January 31, 1983.
*621 COUNSEL
Judith H. Waterman, under appointment by the Court of Appeal, for Defendant and Appellant.
George Deukmejian, Attorney General, Robert H. Philibosian, Chief Assistant Attorney General, Arnold O. Overoye, Assistant Attorney General, Garrett Beaumont and Linda A. Cabatic, Deputy Attorneys General, for Plaintiff and Respondent.
*622 OPINION
FRANSON, Acting P.J. 

BACKGROUND
Appellant was convicted in April 1977 of selling heroin on October 12, 1976. Criminal proceedings were thereafter suspended, and on June 10, 1977, appellant was committed to the California Rehabilitation Center (CRC) as a narcotic addict.
Appellant was released from CRC on outpatient status on December 4, 1977, but was returned to CRC on April 2, 1980. Appellant was again released on outpatient status on November 4, 1980.
On March 19, 1981, pursuant to a condition of appellant's CRC outpatient status, a search of appellant's residence was conducted and narcotic paraphernalia were found. Appellant was jailed, and on April 29, 1981, he was sentenced to county jail for possession of narcotic paraphernalia, a misdemeanor.
On August 14, 1981, the superior court terminated appellant's CRC commitment in the present action and reinstated criminal proceedings for the purpose of sentencing. Appellant was sentenced to 4 years in state prison with 469 days of preprison custody credit plus an additional 249 days conduct credit. Appellant was disallowed any credit for CRC outpatient time. He has appealed.

DISCUSSION
(1) The primary question is whether appellant is entitled to CRC outpatient credit. Appellant relies on former Penal Code section 1203.03, subdivision (g) (at one time lettered as subd. (f)),[1] which authorized outpatient credit to those persons committed to CRC and subsequently sentenced to prison in the same case, to argue that the denial of such credit violates the constitutional prohibition against ex post facto laws. We accept appellant's contention.
*623 The California Supreme Court recently reiterated the basic principles involved in ex post facto analysis of a legislative alteration of criminal punishment: "States are prohibited from adopting ex post facto laws under the Constitutions of both the United States (art. I, § 10, cl. 1), and the State of California (art. I, § 9). The federal Constitution similarly constrains the United States Congress. (Art. I, § 9, cl. 3.) In a very early case (Calder v. Bull (1798) 3 U.S. (3 Dall.) 386 ...), Justice Chase, in the following manner, described those laws which were considered ex post facto: `... Every law that changes the punishment, and inflicts a greater punishment, than the law annexed to the crime, when committed.' (P. 390....) Thus, from its earliest interpretation, the ex post facto clause has barred imposition of a punishment which, after commission of the crime, was increased or made more burdensome." (In re Stanworth (1982) 33 Cal.3d 176, 180 [187 Cal. Rptr. 783, 654 P.2d 1311], italics added.)
In Stanworth the trial court had granted habeas corpus relief to the defendant who had been sentenced to life imprisonment under the Indeterminate Sentence Law (ISL) and the administrative guidelines in effect at the time he was sentenced but whose parole date was fixed on the basis of the Determinate Sentencing Act (DSL) and its implementing regulations. Under the new regulations, defendant's postconviction behavior was not utilized in the same manner in determining his parole release date as under the earlier regulations. The Supreme Court unanimously affirmed, holding that under the ex post facto clauses of the state and federal Constitutions defendant was entitled to parole release consideration under both ISL and the administrative guidelines in effect at the time he was sentenced and DSL and its implementing regulations. Since application of the new guidelines, which reflected basic legislative alterations in the underlying parole scheme, could have resulted in a different award of postconviction credit than provided under the former standards, the standard of punishment was altered to defendant's prejudice in violation of ex post facto principles.
Stanworth notes at page 180 that the United States Supreme Court in Weaver v. Graham (1981) 450 U.S. 24 [67 L.Ed.2d 17, 101 S.Ct. 960], analyzed the federal ex post facto clause within the context of a statute which altered the availability of "gain time for good conduct." The Florida courts had denied Weaver habeas corpus relief on the ground that the allowance of such time "`is an act of grace rather than a vested right and may be withdrawn, modified, or denied.'" (Id., at p. 28 [67 L.Ed.2d at p. 22, 101 S.Ct. at p. 963], quoting Harris v. Wainwright (Fla. 1979) 376 So.2d 855, 856.) The high court corrected that interpretation observing that "our decisions prescribe that two critical elements must be present for a criminal or penal law to be ex post facto: it must be retrospective, that is, it must apply to events occurring before its enactment, and it must disadvantage the offender affected by it. [Citations.] *624 Contrary to the reasoning of the Supreme Court of Florida, a law need not impair a `vested right' to violate the ex post facto prohibition." (Id., at p. 29 [67 L.Ed.2d at p. 23, 101 S.Ct. at p. 964], fns. omitted.) Weaver held that it was unnecessary to decide whether the prospect of gain time was technically part of the inmate's sentence in order "to conclude that it in fact is one determinant of petitioner's prison term  and that his effective sentence is altered once this determinant is changed." (Id., at p. 32 [67 L.Ed. at p. 25, 101 S.Ct. at p. 966].)
Stanworth observes that Weaver "quickly disposes" of the People's claim that because no parole date had been set before the change in guidelines that defendant had no vested right to which the bar against ex post facto law attached. (In re Stanworth, supra, 33 Cal.3d 176 at p. 180.) Quoting from Weaver: "The presence or absence of an affirmative, enforceable right is not relevant, ... Critical to relief under the Ex Post Facto Clause is not an individual's right to less punishment, but the lack of fair notice and governmental restraint when the legislature increases punishment beyond what was prescribed when the crime was consummated." (450 U.S. at p. 30 [67 L.Ed. at p. 24, 101 S.Ct. at p. 965].) In brief, the "critical question is whether the law changes the legal consequences of acts completed before its effective date." (Id., at p. 31 [67 L.Ed.2d at p. 24, 101 S.Ct. at p. 965.) "The tenor of Weaver seems unmistakable: prejudicial changes in punishment enacted after commission of a crime are suspect on ex post facto grounds." (In re Stanworth, supra, at p. 181.)
We glean one overriding rule from Stanworth and Weaver: for ex post facto purposes we compare the sentencing scheme in existence at the time the crime is committed with the sentencing scheme in existence at the time of sentencing. If the latter scheme even in part works to the defendant's disadvantage when compared with the former scheme, the defendant is entitled to the benefit of the former scheme.
In the present case, appellant committed his crime in October 1976 when Penal Code section 1203.03, subdivision (g) (at that time lettered as subd. (f)) allowed outpatient credit for persons committed to CRC. By denying such credits to appellant because he was sentenced to prison after July 1, 1977, appellant will suffer a greater punishment than he would have had the statute not been amended.
Respondent argues that the passage of DSL had an ameliorative effect because the four-year sentence appellant received under DSL was less than the five-year to life sentence appellant would have received under ISL. This argument is grounded on a false premise, i.e., that the July 1, 1977, amendment of Penal Code section 1203.03, subdivision (g) disallowing outpatient credit was a part of the determinate sentence law which became effective on the same date. *625 To the contrary, the Penal Code section 1203.03 amendment deleting the outpatient credit is separate from the determinate sentence law; the Legislature could have left the outpatient credit on the books when it enacted the determinate sentencing law. If this had been done, appellant would have been sentenced to four years in prison with credit for his CRC outpatient time. Thus, the deletion of outpatient credit worked to appellant's disadvantage.[2]
Respondent's reliance on In re Dalton (1981) 117 Cal. App.3d 521 [172 Cal. Rptr. 783] is misplaced. In Dalton, defendant was convicted on April 16, 1975, of forgery. At the time of her crime, Penal Code section 1203.03 did not authorize outpatient credit. Therefore, when defendant was sentenced to state prison without outpatient credit on March 17, 1980, there was no ex post facto problem. The denial of such credit did not increase the punishment defendant would have received had she been sentenced before July 1, 1977.
Since we are deciding this case solely on the basis of ex post facto principles, we need not discuss appellant's equal protection arguments based on In re Martin (1981) 125 Cal. App.3d 896 [178 Cal. Rptr. 445] and In re Taylor (1982) 132 Cal. App.3d 260 [183 Cal. Rptr. 34]. (See also People v. Hankins (1982) 137 Cal. App.3d 694 [187 Cal. Rptr. 210].)
Respondent concedes appellant is entitled to conduct credits for the inpatient time at CRC (Welf. & Inst. Code, § 3201, subd. (c); see In re Martin, supra, 125 Cal. App.3d 896, 900; In re Morales (1981) 115 Cal. App.3d 456, 461 [171 Cal. Rptr. 425]).
Respondent also concedes that appellant is entitled to dual credit for the confinement time directly attributable to both the parole hold and the subsequent narcotic misdemeanor offense. (2) Dual credit may be granted if new charges cause a loss of liberty granted through parole or probation on an earlier unrelated matter. (See People v. Penner (1980) 111 Cal. App.3d 168, 170 [168 Cal. Rptr. 431]; People v. Galloway (1980) 107 Cal. App.3d 709, 712 [165 Cal. Rptr. 771].) The prerequisite for dual credit is that the custody must relate to both matters. Time served on a sentence in one case while awaiting trial on *626 another cannot be the basis for dual credit. Time spent in custody prior to commencement of sentence is credited only where the custody is attributable to proceedings relating to the same conduct for which the defendant has been convicted. (See In re Rojas (1979) 23 Cal.3d 152, 155-157 [151 Cal. Rptr. 649, 588 P.2d 789]; Pen. Code, § 2900.5, subd. (b).) Since the parole hold was placed on appellant as a result of the discovery of the narcotic paraphernalia at his house on March 19, 1981, he remained in custody as a result of the parole hold until April 29, 1981, when he was sentenced to the county jail for possession of the paraphernalia. Appellant is entitled to dual credit for the period of March 19, 1981, to April 29, 1981, because that period of custody is attributable to both the parole hold and the paraphernalia offense.
The judgment is reversed. The matter is remanded to the trial court with directions to give appellant the preprison custody credits as provided in this opinion and to specify such credits in the abstract of judgment as required by law.
Andreen, J., and Stanton, J.,[*] concurred.
NOTES
[1]  Subdivision (f) of Penal Code section 1203.03 was amended in 1975, effective January 1, 1976, and provided: "Time spent by a defendant in confinement in a diagnostic facility of the Department of Corrections pursuant to this section or as an outpatient or inpatient of the California Rehabilitation Center shall be credited on the term of imprisonment in state prison, if any, to which defendant is sentenced in the case." (Italics added, Stats. 1975, ch. 1087, § 5, p. 2651.) Subdivision (f) was relettered as subdivision (g) in 1976 (Stats. 1976, ch. 284, § 1, p. 593) and was amended again in 1977, operative July 1, 1977, to provide credit only for time spent by a defendant as an inpatient of CRC on the term of imprisonment in state prison, if any, to which defendant is sentenced in the case. (Stats. 1977, ch. 165, §§ 21, 98, pp. 656, 680.)
[2]  Even if we should attempt to calculate the actual sentence appellant would have received if the ISL had not been repealed, it is difficult to conclude that he has not been prejudiced by the denial of outpatient credit. We note that under title 15, California Administrative Code, section 2343 outpatient credit granted pursuant to former Penal Code section 1203.03, subdivision (g) "shall be deducted from the minimum term, MEPD, and primary term fixed under any previous regulation." If appellant had been sentenced under the indeterminate law of five years to life, the outpatient credit would be deducted from the minimum five-year term. Moreover, appellant would have been eligible for parole under the ISL upon serving one-third of his minimum term. (See Pen. Code, § 3049.) Thus, if appellant had been sentenced to five years in prison before July 1, 1977, he probably would have been released from prison before August of 1981  the date he was sentenced to four years under the determinate sentence law.
[*]   Assigned by the Chairperson of the Judicial Council.
