@SuppressWarnings("ConstantConditions") @Test public void parseTimeValueFromLanguageInfoFormat() { assertEquals(1, TimeSemanticFn.parseTimeValueFromLanguageInfoFormat("T01:02").hour); assertEquals(20, TimeSemanticFn.parseTimeValueFromLanguageInfoFormat("T20:02").hour); assertEquals(2, TimeSemanticFn.parseTimeValueFromLanguageInfoFormat("T01:02").minute); assertEquals(20, TimeSemanticFn.parseTimeValueFromLanguageInfoFormat("T01:20").minute); assertEquals(24, TimeSemanticFn.parseTimeValueFromLanguageInfoFormat("T24:00").hour); assertEquals(0, TimeSemanticFn.parseTimeValueFromLanguageInfoFormat("T00:00").hour); assertEquals(null, TimeSemanticFn.parseTimeValueFromLanguageInfoFormat("01:02")); assertEquals(null, TimeSemanticFn.parseTimeValueFromLanguageInfoFormat("T01:022")); assertEquals(null, TimeSemanticFn.parseTimeValueFromLanguageInfoFormat("T12:60")); assertEquals(null, TimeSemanticFn.parseTimeValueFromLanguageInfoFormat("T12:-1")); assertEquals(null, TimeSemanticFn.parseTimeValueFromLanguageInfoFormat("T24:01")); assertEquals(null, TimeSemanticFn.parseTimeValueFromLanguageInfoFormat("T25:01")); assertEquals(null, TimeSemanticFn.parseTimeValueFromLanguageInfoFormat("T-1:01")); }
static @Nullable TimeValue parseTimeValueFromLanguageInfoFormat(String s) { if (!s.substring(0,1).equals("T")) return null; Matcher matcher = Pattern.compile("^T([0-9][0-9]):([0-9][0-9])$").matcher(s); if (!matcher.find()) return null; int hour = Integer.parseInt(matcher.group(1)); int minute = Integer.parseInt(matcher.group(2)); if ((hour < 0 || hour > 23 || minute < 0 || minute > 59) && !(hour == 24 && minute == 0)) return null; return new TimeValue(hour, minute); }
TimeSemanticFn extends SemanticFn { static @Nullable TimeValue parseTimeValueFromLanguageInfoFormat(String s) { if (!s.substring(0,1).equals("T")) return null; Matcher matcher = Pattern.compile("^T([0-9][0-9]):([0-9][0-9])$").matcher(s); if (!matcher.find()) return null; int hour = Integer.parseInt(matcher.group(1)); int minute = Integer.parseInt(matcher.group(2)); if ((hour < 0 || hour > 23 || minute < 0 || minute > 59) && !(hour == 24 && minute == 0)) return null; return new TimeValue(hour, minute); } }
TimeSemanticFn extends SemanticFn { static @Nullable TimeValue parseTimeValueFromLanguageInfoFormat(String s) { if (!s.substring(0,1).equals("T")) return null; Matcher matcher = Pattern.compile("^T([0-9][0-9]):([0-9][0-9])$").matcher(s); if (!matcher.find()) return null; int hour = Integer.parseInt(matcher.group(1)); int minute = Integer.parseInt(matcher.group(2)); if ((hour < 0 || hour > 23 || minute < 0 || minute > 59) && !(hour == 24 && minute == 0)) return null; return new TimeValue(hour, minute); }  }
TimeSemanticFn extends SemanticFn { static @Nullable TimeValue parseTimeValueFromLanguageInfoFormat(String s) { if (!s.substring(0,1).equals("T")) return null; Matcher matcher = Pattern.compile("^T([0-9][0-9]):([0-9][0-9])$").matcher(s); if (!matcher.find()) return null; int hour = Integer.parseInt(matcher.group(1)); int minute = Integer.parseInt(matcher.group(2)); if ((hour < 0 || hour > 23 || minute < 0 || minute > 59) && !(hour == 24 && minute == 0)) return null; return new TimeValue(hour, minute); }  DerivationStream call(final Example ex, final SemanticFn.Callable c); }
TimeSemanticFn extends SemanticFn { static @Nullable TimeValue parseTimeValueFromLanguageInfoFormat(String s) { if (!s.substring(0,1).equals("T")) return null; Matcher matcher = Pattern.compile("^T([0-9][0-9]):([0-9][0-9])$").matcher(s); if (!matcher.find()) return null; int hour = Integer.parseInt(matcher.group(1)); int minute = Integer.parseInt(matcher.group(2)); if ((hour < 0 || hour > 23 || minute < 0 || minute > 59) && !(hour == 24 && minute == 0)) return null; return new TimeValue(hour, minute); }  DerivationStream call(final Example ex, final SemanticFn.Callable c);  }