diff --git a/cpp/src/phonenumbers/phonenumbermatcher.cc b/cpp/src/phonenumbers/phonenumbermatcher.cc index e7f4e6645..d36f6c2fa 100644 --- a/cpp/src/phonenumbers/phonenumbermatcher.cc +++ b/cpp/src/phonenumbers/phonenumbermatcher.cc @@ -305,7 +305,7 @@ class PhoneNumberMatcherRegExps : public Singleton { "(?:(?:[0-3]?\\d/[01]?\\d)|" "(?:[01]?\\d/[0-3]?\\d))/(?:[12]\\d)?\\d{2}")), time_stamps_(regexp_factory_->CreateRegExp( - "[12]\\d{3}[-/]?[01]\\d[-/]?[0-3]\\d [0-2]\\d$")), + "[12]\\d{3}[-/]?[01]\\d[-/]?[0-3]\\d +[0-2]\\d$")), time_stamps_suffix_(regexp_factory_->CreateRegExp(":[0-5]\\d")), matching_brackets_(regexp_factory_->CreateRegExp( StrCat(leading_maybe_matched_bracket_, non_parens_, "+", diff --git a/cpp/test/phonenumbers/phonenumbermatcher_test.cc b/cpp/test/phonenumbers/phonenumbermatcher_test.cc index 8cd1b0549..a1c72c3c6 100644 --- a/cpp/test/phonenumbers/phonenumbermatcher_test.cc +++ b/cpp/test/phonenumbers/phonenumbermatcher_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Author: Lara Rennie - #include "phonenumbers/phonenumbermatcher.h" #include @@ -811,6 +809,10 @@ static const NumberTest kImpossibleCases[] = { NumberTest("2012-01-02 08:00", RegionCode::US()), NumberTest("2012/01/02 08:00", RegionCode::US()), NumberTest("20120102 08:00", RegionCode::US()), + NumberTest("2014-04-12 04:04 PM", RegionCode::US()), + NumberTest("2014-04-12  04:04 PM", RegionCode::US()), + NumberTest("2014-04-12  04:04 PM", RegionCode::US()), + NumberTest("2014-04-12 04:04 PM", RegionCode::US()), }; // Strings with number-like things that should only be found under "possible". diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java index f9731ddcc..34e8d1634 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java @@ -78,7 +78,7 @@ final class PhoneNumberMatcher implements Iterator { * trailing ":\d\d" -- that is covered by TIME_STAMPS_SUFFIX. */ private static final Pattern TIME_STAMPS = - Pattern.compile("[12]\\d{3}[-/]?[01]\\d[-/]?[0-3]\\d [0-2]\\d$"); + Pattern.compile("[12]\\d{3}[-/]?[01]\\d[-/]?[0-3]\\d +[0-2]\\d$"); private static final Pattern TIME_STAMPS_SUFFIX = Pattern.compile(":[0-5]\\d"); /** diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java index 511a1684f..4a2dc11a5 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java @@ -440,6 +440,10 @@ public class PhoneNumberMatcherTest extends TestMetadataTestCase { new NumberTest("2012-01-02 08:00", RegionCode.US), new NumberTest("2012/01/02 08:00", RegionCode.US), new NumberTest("20120102 08:00", RegionCode.US), + new NumberTest("2014-04-12 04:04 PM", RegionCode.US), + new NumberTest("2014-04-12  04:04 PM", RegionCode.US), + new NumberTest("2014-04-12  04:04 PM", RegionCode.US), + new NumberTest("2014-04-12 04:04 PM", RegionCode.US), }; /** diff --git a/tools/java/common/src/com/google/i18n/phonenumbers/BuildMetadataFromXml.java b/tools/java/common/src/com/google/i18n/phonenumbers/BuildMetadataFromXml.java index f1f39473c..d36273f8b 100644 --- a/tools/java/common/src/com/google/i18n/phonenumbers/BuildMetadataFromXml.java +++ b/tools/java/common/src/com/google/i18n/phonenumbers/BuildMetadataFromXml.java @@ -242,8 +242,9 @@ public class BuildMetadataFromXml { LOGGER.log(Level.SEVERE, "A maximum of one intlFormat pattern for a numberFormat element should be " + "defined."); - throw new RuntimeException("Invalid number of intlFormat patterns for country: " + - metadata.getId()); + String countryId = metadata.getId().length() > 0 ? + metadata.getId() : Integer.toString(metadata.getCountryCode()); + throw new RuntimeException("Invalid number of intlFormat patterns for country: " + countryId); } else if (intlFormatPattern.getLength() == 0) { // Default to use the same as the national pattern if none is defined. intlFormat.mergeFrom(nationalFormat); @@ -275,11 +276,13 @@ public class BuildMetadataFromXml { format.setPattern(validateRE(numberFormatElement.getAttribute(PATTERN))); NodeList formatPattern = numberFormatElement.getElementsByTagName(FORMAT); - if (formatPattern.getLength() != 1) { - LOGGER.log(Level.SEVERE, - "Only one format pattern for a numberFormat element should be defined."); - throw new RuntimeException("Invalid number of format patterns for country: " + - metadata.getId()); + int numFormatPatterns = formatPattern.getLength(); + if (numFormatPatterns != 1) { + LOGGER.log(Level.SEVERE, "One format pattern for a numberFormat element should be defined."); + String countryId = metadata.getId().length() > 0 ? + metadata.getId() : Integer.toString(metadata.getCountryCode()); + throw new RuntimeException("Invalid number of format patterns (" + numFormatPatterns + + ") for country: " + countryId); } format.setFormat(formatPattern.item(0).getFirstChild().getNodeValue()); } diff --git a/tools/java/cpp-build/target/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar b/tools/java/cpp-build/target/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar index 73fd2e828..0b156cc84 100644 Binary files a/tools/java/cpp-build/target/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar and b/tools/java/cpp-build/target/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar differ diff --git a/tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar b/tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar index 53579b5b4..ea8239146 100644 Binary files a/tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar and b/tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar differ