Calculates the breeding cage's duration.

        This is relative to the current date (if alive) or the date of inactivation (if not).
        The duration is formatted in days.
328574
def duration(self):
        """"""
        if self.End:
            age =  self.End - self.Start
        else:    
            age =  datetime.date.today() - self.Start
        return age.days
910
private Duration getDuration(TimeUnit units, Double duration)
   {
      Duration result = null;
      if (duration != null)
      {
         double durationValue = duration.doubleValue() * 100.0;

         switch (units)
         {
            case MINUTES:
            {
               durationValue *= MINUTES_PER_DAY;
               break;
            }

            case HOURS:
            {
               durationValue *= HOURS_PER_DAY;
               break;
            }

            case DAYS:
            {
               durationValue *= 3.0;
               break;
            }

            case WEEKS:
            {
               durationValue *= 0.6;
               break;
            }

            case MONTHS:
            {
               durationValue *= 0.15;
               break;
            }

            default:
            {
               throw new IllegalArgumentException("Unsupported time units " + units);
            }
         }

         durationValue = Math.round(durationValue) / 100.0;

         result = Duration.getInstance(durationValue, units);
      }

      return result;
   }
108634
def EXPIRING_TOKEN_LIFESPAN(self):
        
        try:
            val = settings.EXPIRING_TOKEN_LIFESPAN
        except AttributeError:
            val = timedelta(days=30)

        return val
282577
def tenure(self):
        
        if self.end_date:
            return round((date.end_date - self.start_date).days / 365., 2)
        else:
            return round((date.today() - self.start_date).days / 365., 2)
512279
def male_breeding_location_type(self):
        """"""
        if int(self.Male.all()[0].Cage) == int(self.Cage):
            type = "resident breeder"
        else:
            type = "non-resident breeder"
        return type
641751
def duration(
    days=0,  # type: float
    seconds=0,  # type: float
    microseconds=0,  # type: float
    milliseconds=0,  # type: float
    minutes=0,  # type: float
    hours=0,  # type: float
    weeks=0,  # type: float
    years=0,  # type: float
    months=0,  # type: float
):  # type: (...) -> Duration
    
    return Duration(
        days=days,
        seconds=seconds,
        microseconds=microseconds,
        milliseconds=milliseconds,
        minutes=minutes,
        hours=hours,
        weeks=weeks,
        years=years,
        months=months,
    )
212064
def total_duration(self) -> datetime.timedelta:
        
        total = datetime.timedelta()
        for interval in self.intervals:
            total += interval.duration()
        return total
1247775
def _calc_eta(self):
        
        elapsed = self._elapsed()
        if self.cnt == 0 or elapsed < 0.001:
            return None
        rate = float(self.cnt) / elapsed
        self.eta = (float(self.max_iter) - float(self.cnt)) / rate
1073948
def SD(self, days=45):
    
    if len(self.raw_data) >= days:
      data = self.raw_data[-days:]
      data_avg = float(sum(data) / days)
      data2 = []
      for x in data:
        data2.append((x - data_avg ) ** 2)

      return math.sqrt(sum(data2) / len(data2))
    else:
      return 0
679031
private IntVar makeDuration() throws SchedulerException {
        if (start.isInstantiated() && end.isInstantiated()) {
            int d = end.getValue() - start.getValue();
            return rp.makeDuration(d, d, lblPrefix, "_duration");
        } else if (start.isInstantiated()) {
            if (start.isInstantiatedTo(0)) {
                return end;
            }
            return rp.getModel().intOffsetView(end, -start.getValue());
        }
        int inf = end.getLB() - start.getUB();
        if (inf < 0) {
            inf = 0;
        }
        int sup = end.getUB() - start.getLB();
        return rp.makeDuration(sup, inf, lblPrefix, "_duration");
    }
416103
def duration_outside_nwh(
            self,
            starttime: datetime.time = datetime.time(NORMAL_DAY_START_H),
            endtime: datetime.time = datetime.time(NORMAL_DAY_END_H)) \
            -> datetime.timedelta:
        
        total = datetime.timedelta()
        for interval in self.intervals:
            total += interval.duration_outside_nwh(starttime, endtime)
        return total
1150095
def total_duration(self):
        
        duration = 0

        for utterance in self.utterances.values():
            duration += utterance.duration

        return duration
47781
def duration(label, stop_it=True, stop_at=None):
    """"""

    if label not in labels:
        return None

    if "duration" in labels[label]:
        return Duration(labels[label]["duration"])

    if stop_it:
        return stop(label, at=stop_at)
    else:
        return None
1206237
def duration(self):
        
        with self.container.open_if_needed(mode='r') as cnt:
            samples, sr = cnt.get(self.key)

            return samples.shape[0] / sr
220680
def timesince(self, when):
        
        units = (
            ("year",   60 * 60 * 24 * 365),
            ("week",   60 * 60 * 24 * 7),
            ("day",    60 * 60 * 24),
            ("hour",   60 * 60),
            ("minute", 60),
            ("second", 1),
        )
        delta = datetime.now() - when
        total_seconds = delta.days * 60 * 60 * 24 + delta.seconds
        parts = []
        for name, seconds in units:
            value = total_seconds / seconds
            if value > 0:
                total_seconds %= seconds
                s = "s" if value != 1 else ""
                parts.append("%s %s%s" % (value, name, s))
        return " and ".join(", ".join(parts).rsplit(", ", 1))
801486
def duration(start, end=None):
    
    if not end:
        end = datetime.now()
    td = end - start
    return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 1000000) \
        / 1000000.0
126722
def duration(self):
        
        if self._stop_instant is None:
            return int((instant() - self._start_instant) * 1000)
        if self._duration is None:
            self._duration = int((self._stop_instant - self._start_instant) * 1000)
        return self._duration