Merge pull request #419 from dylanleonard/feature_time_spinner_fix

Time Spinner Local Profile Fix
This commit is contained in:
Milos Kozak 2017-09-18 21:06:34 +02:00 committed by GitHub
commit a98d2e846f

View file

@ -85,15 +85,15 @@ public class DateUtil {
} }
public static int toSeconds(String hh_colon_mm) { public static int toSeconds(String hh_colon_mm) {
Pattern p = Pattern.compile("(\\d+):(\\d+)( a.m.| p.m.|)"); Pattern p = Pattern.compile("(\\d+):(\\d+)( a.m.| p.m.| AM | PM)");
Matcher m = p.matcher(hh_colon_mm); Matcher m = p.matcher(hh_colon_mm);
int retval = 0; int retval = 0;
if (m.find()) { if (m.find()) {
retval = SafeParse.stringToInt(m.group(1)) * 60 * 60 + SafeParse.stringToInt(m.group(2)) * 60; retval = SafeParse.stringToInt(m.group(1)) * 60 * 60 + SafeParse.stringToInt(m.group(2)) * 60;
if (m.group(3).equals(" .a.m") && m.group(1).equals("12")) if ((m.group(3).equals(" a.m.") || m.group(3).equals(" AM")) && m.group(1).equals("12"))
retval -= 12 * 60 * 60; retval -= 12 * 60 * 60;
if (m.group(3).equals(" p.m.") && !m.group(1).equals("12")) if ((m.group(3).equals(" p.m.") || m.group(3).equals(" PM")) && !(m.group(1).equals("12")))
retval += 12 * 60 * 60; retval += 12 * 60 * 60;
} }
return retval; return retval;