コード例 #1
0
    def duration(self) -> DateRange:
        """Generates a DateRange for the days covered by the supervision period.  Since DateRange is never open,
        if the supervision period is still active, then the exclusive upper bound of the range is set to tomorrow.
        """
        if not self.start_date:
            raise ValueError(
                f'Expected start date for period {self.supervision_period_id}, found None'
            )

        return DateRange.from_maybe_open_range(start_date=self.start_date,
                                               end_date=self.termination_date)
コード例 #2
0
    def duration(self) -> DateRange:
        """Generates a DateRange for the days covered by the incarceration period.  Since DateRange is never open,
        if the incarceration period is still active, then the exclusive upper bound of the range is set to tomorrow.
        """
        if not self.admission_date:
            raise ValueError(
                f'Expected start date for period {self.incarceration_period_id}, found None'
            )

        if (not self.release_date
                and self.status != StateIncarcerationPeriodStatus.IN_CUSTODY):
            raise ValueError(
                "Unexpected missing release date. _infer_missing_dates_and_statuses is not properly"
                " setting missing dates.")

        return DateRange.from_maybe_open_range(start_date=self.admission_date,
                                               end_date=self.release_date)