/*
Returns the duration, in seconds, by the
duration name.  Optionally provide FullPage
boolean to get an appropriate full page cache
time setting.
178686
public function getDuration()
    {
        $name = trim((string) $this->getParameter('name'));
        $fullPage = StringUtils::strToBool((string)$this->getParameter('FullPage'));
        if (empty($name))
            $name = 'default';

        if (in_array($name, explode(',', 'none,never,off,0,zero,no')))
            return 0;

        if (!array_key_exists($name, $this->durations))
            $name = 'default';

        $duration = abs((int)$this->durations[$name]);

        if (!$fullPage || $duration < 1)
            return $duration;

        // full page cache duration should be half the cache time
        return ceil($duration/2);
    }
983548
public double getDurationMs() {
        double durationMs = 0;
        for (Duration duration : durations) {
            if (duration.taskFinished()) {
                durationMs += duration.getDurationMS();
            }
        }
        return durationMs;
    }
1316487
def duration(seconds):
    """"""
    if seconds < 1:
        return 'less than 1 sec'
    seconds = int(round(seconds))
    components = []
    for magnitude, label in ((3600, 'hr'), (60, 'min'), (1, 'sec')):
        if seconds >= magnitude:
            components.append('{} {}'.format(seconds // magnitude, label))
            seconds %= magnitude
    return ' '.join(components)
1104634
protected static long validateDuration(@Nullable Duration value, String name) {
        if (value == null) {
            return -1;
        }

        checkArgument(!value.isNegative(), "%s: %s (expected: >= 0)", name, value);
        return value.getSeconds();
    }
551546
public OvhOrder dedicated_server_serviceName_feature_duration_GET(String serviceName, String duration, OvhOrderableSysFeatureEnum feature) throws IOException {
		String qPath = "/order/dedicated/server/{serviceName}/feature/{duration}";
		StringBuilder sb = path(qPath, serviceName, duration);
		query(sb, "feature", feature);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhOrder.class);
	}
65686
public Long getDurationOfLastSuccessfulOnAgent(String pipelineName, String stageName, JobInstance job) {
        String key = job.getBuildDurationKey(pipelineName, stageName);
        Long duration;
        try {
            duration = (Long) cache.getFromCache(key, CacheEntry.INDEFINITE_EXPIRY);
        } catch (NeedsRefreshException nre) {
            boolean updated = false;
            try {
                duration = recalculateBuildDuration(pipelineName, stageName, job);
                cache.putInCache(key, duration);
                updated = true;
            } finally {
                if (!updated) {
                    // It is essential that cancelUpdate is called if the
                    // cached content could not be rebuilt
                    cache.cancelUpdate(key);
                    LOGGER.warn("refresh cancelled for {}", key);
                }
            }
        }
        return duration;
    }
554840
@ManagedAttribute(
         description = "Number of seconds since cache started",
         displayName = "Seconds since cache started",
         units = Units.SECONDS,
         measurementType = MeasurementType.TRENDSUP,
         displayType = DisplayType.SUMMARY
   )
   @Deprecated
   public long getElapsedTime() {
      // backward compatibility as we renamed ElapsedTime to TimeSinceStart
      return getTimeSinceStart();
   }
1356860
@Override
	public long getTimeToLive(String baseName, Locale locale) {
		if (baseName == null || locale == null) {
			throw new NullPointerException();
		}
		return TTL_DONT_CACHE;
	}
1128861
public CachedType get(String fullQualifiedName) {
        CachedType cachedType = lruCache.getIfPresent(fullQualifiedName);
        if (cachedType != null) {
            return cachedType;
        }
        cachedType = softCache.getIfPresent(fullQualifiedName);
        if (cachedType != null) {
            lruCache.put(fullQualifiedName, cachedType);
        }
        return cachedType;
    }
131058
protected int getAllowCachedTimerData(J2EEName j2eeName) {
        Integer allowCachedTimerData = null;
        Map<String, Integer> localAllowCachedTimerDataMap = allowCachedTimerDataMap;
        if (localAllowCachedTimerDataMap != null) {
            allowCachedTimerData = localAllowCachedTimerDataMap.get(j2eeName.toString());
            if (allowCachedTimerData == null) {
                allowCachedTimerData = localAllowCachedTimerDataMap.get("*");
            }
        }
        return allowCachedTimerData != null ? allowCachedTimerData : 0;
    }
482980
private static QName getDurationType(Duration value) {
        boolean hasYearMonth = (
                value.isSet(DatatypeConstants.YEARS)  ||
                value.isSet(DatatypeConstants.MONTHS)
                );
        boolean hasDayTime = (
                value.isSet(DatatypeConstants.DAYS)    ||
                value.isSet(DatatypeConstants.HOURS)   ||
                value.isSet(DatatypeConstants.MINUTES) ||
                value.isSet(DatatypeConstants.SECONDS)
                );

        if (hasYearMonth && !hasDayTime) {
            return DatatypeConstants.DURATION_YEARMONTH;
        } else if ((!hasYearMonth) && hasDayTime) {
            return DatatypeConstants.DURATION_DAYTIME;
        }

        throw new IllegalArgumentException("value must be yearMonthDuration or dayTimeDuration: "+value);
    }
1279293
def accessed(filename):
    '''
    
    '''
    if isinstance(filename, file):
        filename = filename.name

    return duration(os.stat(filename)[stat.ST_ATIME])
1009036
public long getDuration() {
		Status s = status;
		if (s == Status.READY)
			return 0;
		if (s == Status.RUNNING)
			return System.currentTimeMillis() - startTime;
		return finishTime - startTime;
	}
674035
public function getCacheLifetime()
    {
        if ($this->cacheLifetime === null) {
            $this->setCacheLifetime($this->config->get('concrete.i18n.community_translation.cache_lifetime', 3600));
        }

        return $this->cacheLifetime;
    }
827727
@Override
    protected long overallEndTime() {
        long ret = super.overallEndTime();

        for (Node child : nodes) {
            long childEndTime = child.overallEndTime();

            if (childEndTime > ret) {
                ret = childEndTime;
            }
        }

        return ret;
    }
347268
def _get_timestamp_cached(dirname_full, remove):
    
    if dirname_full not in TIMESTAMP_CACHE:
        mtime = _get_timestamp(dirname_full, remove)
        TIMESTAMP_CACHE[dirname_full] = mtime
    return TIMESTAMP_CACHE[dirname_full]
279632
long getCacheTimeInSec(HttpHeaders httpHeaders) {
    long cacheTimeInSec = 0;
    if (httpHeaders.getCacheControl() != null) {
      for (String arg : httpHeaders.getCacheControl().split(",")) {
        Matcher m = MAX_AGE_PATTERN.matcher(arg);
        if (m.matches()) {
          cacheTimeInSec = Long.parseLong(m.group(1));
          break;
        }
      }
    }
    if (httpHeaders.getAge() != null) {
      cacheTimeInSec -= httpHeaders.getAge();
    }
    return Math.max(0, cacheTimeInSec);
  }