| 104 | |
| 105 | |
| 106 | def parseTime(timeStr): |
| 107 | if ":" not in timeStr: |
| 108 | return float(timeStr) |
| 109 | regex = re.compile(constants.PARSE_TIME_REGEX) |
| 110 | parts = regex.match(timeStr) |
| 111 | if not parts: |
| 112 | return |
| 113 | parts = parts.groupdict() |
| 114 | time_params = {} |
| 115 | for (name, param) in parts.items(): |
| 116 | if param: |
| 117 | if name == "miliseconds": |
| 118 | time_params["microseconds"] = int(param) * 1000 |
| 119 | else: |
| 120 | time_params[name] = int(param) |
| 121 | return datetime.timedelta(**time_params).total_seconds() |
| 122 | |
| 123 | |
| 124 | def formatTime(timeInSeconds, weeksAsTitles=True): |