Returns a parsed duration value.
172601
static long parseDuration(String key, @Nullable String value) {
    requireArgument((value != null) && !value.isEmpty(), "value of key %s omitted", key);
    @SuppressWarnings("NullAway")
    String duration = value.substring(0, value.length() - 1);
    return parseLong(key, duration);
  }
909835
def get_duration(self):
        """"""

        doc = self._request(self.ws_prefix + ".getInfo", True)

        return _number(_extract(doc, "duration"))
1084643
def duration(self):
        """"""
        self._duration = self.lib.iperf_get_test_duration(self._test)
        return self._duration
870523
public static final Duration parseDuration(String value)
   {
      Duration result = null;
      if (value != null)
      {
         int split = value.indexOf(' ');
         if (split != -1)
         {
            double durationValue = Double.parseDouble(value.substring(0, split));
            TimeUnit durationUnits = parseTimeUnits(value.substring(split + 1));

            result = Duration.getInstance(durationValue, durationUnits);

         }
      }
      return result;
   }
1668
def parse_duration_with_start(start, duration):
    
    elements = _parse_duration_string(_clean(duration))
    year, month = _year_month_delta_from_elements(elements)

    end = start.replace(
        year=start.year + year,
        month=start.month + month
    )

    del elements['years']
    del elements['months']

    end += _timedelta_from_elements(elements)

    return start, end - start
224523
public static long parseDuration(CharSequence duration)
    {
        // Match the duration against the regular expression.
        Matcher matcher = DURATION_PATTERN.matcher(duration);

        // Check that the argument is of the right format accepted by this method.
        if (!matcher.matches())
        {
            throw new IllegalArgumentException("The duration definition is not in the correct format.");
        }

        // This accumulates the duration.
        long result = 0;

        int numGroups = matcher.groupCount();

        // Extract the days.
        if (numGroups >= 1)
        {
            String daysString = matcher.group(1);
            result +=
                (daysString == null)
                ? 0 : (Long.parseLong(daysString.substring(0, daysString.length() - 1)) * 24 * 60 * 60 * 1000);
        }

        // Extract the hours.
        if (numGroups >= 2)
        {
            String hoursString = matcher.group(2);
            result +=
                (hoursString == null)
                ? 0 : (Long.parseLong(hoursString.substring(0, hoursString.length() - 1)) * 60 * 60 * 1000);
        }

        // Extract the minutes.
        if (numGroups >= 3)
        {
            String minutesString = matcher.group(3);
            result +=
                (minutesString == null)
                ? 0 : (Long.parseLong(minutesString.substring(0, minutesString.length() - 1)) * 60 * 1000);
        }

        // Extract the seconds.
        if (numGroups >= 4)
        {
            String secondsString = matcher.group(4);
            result +=
                (secondsString == null)
                ? 0 : (Long.parseLong(secondsString.substring(0, secondsString.length() - 1)) * 1000);
        }

        return result;
    }
68564
def duration(self):
        
        if not self.started:
            return None
        start = self.started
        end = self.completed
        if not end:
            end = datetime.utcnow()
        return end - start
244906
def duration(self):
        
        duration = 0.0
        if len(self.events) > 0:
            first = datetime.fromtimestamp(self.events[0]['timestamp'])
            last = datetime.fromtimestamp(self.events[-1]['timestamp'])
            duration = (last - first).total_seconds()
        return duration
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
946673
def duration(self):
        
        return max([x.comp_location + x.duration
                    for x in self.segments])
1019441
function duration (time) {
  var number = parseFloat(time)
  switch (unit(time)) {
    case null:
    case 'ms': return number
    case 's': return number * 1000
    case 'm': return number * 60000
    case 'h': return number * 3600000
    case 'd': return number * 86400000
    case 'w': return number * 604800000
    default: return null
  }
}
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)
300886
def strduration (duration):
    """"""
    if duration < 0:
        duration = abs(duration)
        prefix = "-"
    else:
        prefix = ""
    duration = math.ceil(duration)
    if duration >= SECONDS_PER_HOUR: # 1 hour
        # time, in hours:minutes:seconds
        return "%s%02d:%02d:%02d" % (prefix, duration // SECONDS_PER_HOUR,
                                   (duration % SECONDS_PER_HOUR) // SECONDS_PER_MINUTE,
                                    duration % SECONDS_PER_MINUTE)
    else:
        # time, in minutes:seconds
        return "%s%02d:%02d" % (prefix, duration // SECONDS_PER_MINUTE,
                                 duration % SECONDS_PER_MINUTE)
864427
def parse_duration(string):
    
    if string.isdigit():
        return int(string)
    try:
        return float(string)
    except ValueError:
        pass
    string = string.rstrip()
    for (suf, mult) in DURATION_SUFFIX_MAP.items():
        if string.lower().endswith(suf):
            try:
                return parse_duration(string[:-len(suf)].strip()) * mult
            except TypeError:
                return
620438
@NonNull
    public static String convertDuration(@IntRange(from = 1) long duration) {
        duration /= 1000;
        int hour = (int) (duration / 3600);
        int minute = (int) ((duration - hour * 3600) / 60);
        int second = (int) (duration - hour * 3600 - minute * 60);

        String hourValue = "";
        String minuteValue;
        String secondValue;
        if (hour > 0) {
            if (hour >= 10) {
                hourValue = Integer.toString(hour);
            } else {
                hourValue = "0" + hour;
            }
            hourValue += ":";
        }
        if (minute > 0) {
            if (minute >= 10) {
                minuteValue = Integer.toString(minute);
            } else {
                minuteValue = "0" + minute;
            }
        } else {
            minuteValue = "00";
        }
        minuteValue += ":";
        if (second > 0) {
            if (second >= 10) {
                secondValue = Integer.toString(second);
            } else {
                secondValue = "0" + second;
            }
        } else {
            secondValue = "00";
        }
        return hourValue + minuteValue + secondValue;
    }
792802
public static final Duration getDuration(double value, TimeUnit type)
   {
      double duration;
      // Value is given in 1/10 of minute
      switch (type)
      {
         case MINUTES:
         case ELAPSED_MINUTES:
         {
            duration = value / 10;
            break;
         }

         case HOURS:
         case ELAPSED_HOURS:
         {
            duration = value / 600; // 60 * 10
            break;
         }

         case DAYS:
         {
            duration = value / 4800; // 8 * 60 * 10
            break;
         }

         case ELAPSED_DAYS:
         {
            duration = value / 14400; // 24 * 60 * 10
            break;
         }

         case WEEKS:
         {
            duration = value / 24000; // 5 * 8 * 60 * 10
            break;
         }

         case ELAPSED_WEEKS:
         {
            duration = value / 100800; // 7 * 24 * 60 * 10
            break;
         }

         case MONTHS:
         {
            duration = value / 96000; // 4 * 5 * 8 * 60 * 10
            break;
         }

         case ELAPSED_MONTHS:
         {
            duration = value / 432000; // 30 * 24 * 60 * 10
            break;
         }

         default:
         {
            duration = value;
            break;
         }
      }
      return (Duration.getInstance(duration, type));
   }
1092075
public static DayDuration valueOf(String duration) {
		int spacePos = duration.indexOf(' ');
		if(spacePos == -1) throw new IllegalArgumentException("Space not found in duration: " + duration);
		return getInstance(
			Integer.parseInt(duration.substring(0, spacePos)),
			Unit.valueOfUnit(duration.substring(spacePos + 1))
		);
	}