Update Timeline regex

Regex now looks for the new types of short and long timestamps.
This commit is contained in:
Nathan Mascitelli 2019-02-10 18:01:00 -05:00
parent 9180be85ba
commit 96b0336b2c
2 changed files with 7 additions and 7 deletions

View File

@ -76,11 +76,11 @@ public final class Converter {
/** Converts milliseconds to a string containing hours and minutes */
public static String getDurationStringShort(int duration) {
int h = duration / HOURS_MIL;
int rest = duration - h * HOURS_MIL;
int m = rest / MINUTES_MIL;
int minutes = duration / MINUTES_MIL;
int rest = duration - minutes * MINUTES_MIL;
int seconds = rest / SECONDS_MIL;
return String.format(Locale.getDefault(), "%02d:%02d", h, m);
return String.format(Locale.getDefault(), "%02d:%02d", minutes, seconds);
}
/** Converts long duration string (HH:MM:SS) to milliseconds. */
@ -100,8 +100,8 @@ public final class Converter {
if (parts.length != 2) {
return 0;
}
return Integer.parseInt(parts[0]) * 3600 * 1000 +
Integer.parseInt(parts[1]) * 1000 * 60;
return Integer.parseInt(parts[0]) * 60 * 1000 +
Integer.parseInt(parts[1]) * 1000;
}
/** Converts milliseconds to a localized string containing hours and minutes */

View File

@ -68,7 +68,7 @@ public class Timeline {
private static final Pattern TIMECODE_LINK_REGEX = Pattern.compile("antennapod://timecode/((\\d+))");
private static final String TIMECODE_LINK = "<a class=\"timecode\" href=\"antennapod://timecode/%d\">%s</a>";
private static final Pattern TIMECODE_REGEX = Pattern.compile("\\b(?:(?:(([0-9][0-9])):))?(([0-9][0-9])):(([0-9][0-9]))\\b");
private static final Pattern TIMECODE_REGEX = Pattern.compile("\\b(?:(?:([01]?\\d|2[0-3]):)?([0-5]?\\d):)?([0-5]?\\d)\\b");
private static final Pattern LINE_BREAK_REGEX = Pattern.compile("<br */?>");