This might work for you.
timeRules = {"m" -> "Minutes", "hr" -> "Hour", "min" -> "Minutes",
"h" -> "Hour"};
ParseTime[timeString_] :=
With[{numberString = First@StringCases[timeString, NumberString]},
Quantity @@ {ToExpression@numberString,
StringDelete[timeString, numberString] /. timeRules}];
ParseTimeString[bracketedTimeString_] :=
ParseTime[#] & /@
StringSplit[bracketedTimeString, {"[", ",", ", ", "]"}];
ApproximateTime[bracketedTimeString_] :=
With[{parsedTime = ParseTimeString[bracketedTimeString]},
If[Length[parsedTime] > 1,
Around[Median[parsedTime], Median[parsedTime] - Min[parsedTime]],
First@parsedTime]]
Given an input of
aString = "[30m,1hr]"
ApproximateTime[aString]
It returns
Around[
Quantity[0.75, "Hours"],
Quantity[15., "Minutes"]]
EDIT:
Made a couple of minor changes so that I didn't assume the first element was the smallest and to handle the case where the string is something like this: "[20m]".
ApproximateTime["[20m]"]
(* Quantity[20, "Minutes"] *)
EDIT 2:
More minor changes in case there are spaces after the comma. And a new test case.
ApproximateTime[#] & /@ {"[20m,1h]", "[30m,45m]", "[45m, 2h]"}
(* {Around[
Quantity[0.6666666666666666, "Hours"],
Quantity[20., "Minutes"]],
Quantity[Around[37.5, 7.5], "Minutes"], Around[
Quantity[1.375, "Hours"],
Quantity[37.5, "Minutes"]]} *)
SemanticInterpretation
picks up when parsing time lengths? $\endgroup$min
instead ofm
(though "m" is more convenient in my case). $\endgroup$