Sync properly to Google internal repo
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6e77568..cf9375d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,6 @@
   * Parse Eras in DateFormat.
   * Update pubspec.yaml to allow newer version of fixnum.
   * Improvements to the compiled size of generated messages code with dart2js.
-  * Update Intl pubspec to allow newer version of fixnum
   * Allow adjacent literal strings to be used for message names/descriptions.
   * Provide a better error message for some cases of bad parameters
     to plural/gender/select messages.
diff --git a/lib/intl.dart b/lib/intl.dart
index 0e131a9..10381db 100644
--- a/lib/intl.dart
+++ b/lib/intl.dart
@@ -139,14 +139,14 @@
    * will be substituted in the message.
    *
    * The [message_str] is the string to be translated, which may be interpolated
-   * based on one or more variables. The [name] of the message must
-   * match the enclosing function name. For methods, it can also be
+   * based on one or more variables. The [name] of the message must 
+   * match the enclosing function name. For methods, it can also be 
    * className_methodName. So for a method hello in class Simple, the name
    * can be either "hello" or "Simple_hello". The name must also be globally
    * unique in the program, so the second form can make it easier to distinguish
    * messages with the same name but in different classes.
    * The [args] repeats the arguments of the enclosing
-   * function, [desc] provides a description of usage,
+   * function, [desc] provides a description of usage, 
    * [examples] is a Map of exmaples for each interpolated variable. For example
    *       hello(yourName) => Intl.message(
    *         "Hello, $yourName",
@@ -187,6 +187,12 @@
   String get locale => _locale;
 
   /**
+   * Return true if the locale exists, or if it is null. The null case
+   * is interpreted to mean that we use the default locale.
+   */
+  static bool _localeExists(localeName) => DateFormat.localeExists(localeName);
+
+  /**
    * Given [newLocale] return a locale that we have data for that is similar
    * to it, if possible.
    *
diff --git a/lib/src/intl/date_format.dart b/lib/src/intl/date_format.dart
index 3921957..40ff895 100644
--- a/lib/src/intl/date_format.dart
+++ b/lib/src/intl/date_format.dart
@@ -57,7 +57,7 @@
  * For each skeleton there is a named constructor that can be used to create it.
  * It's also possible to pass the skeleton as a string, but the constructor
  * is preferred.
- *
+ * 
  *      ICU Name                   Skeleton
  *      --------                   --------
  *      DAY                          d
@@ -115,11 +115,11 @@
  *
  * Explicit Pattern Syntax: Formats can also be specified with a pattern string.
  * This can be used for formats that don't have a skeleton available, but these
- * will not adapt to different locales. For example, in an explicit pattern the
- * letters "H" and "h" are available for 24 hour and 12 hour time formats
+ * will not adapt to different locales. For example, in an explicit pattern the 
+ * letters "H" and "h" are available for 24 hour and 12 hour time formats 
  * respectively. But there isn't a way in an explicit pattern to get the
  * behaviour of the "j" skeleton, which prints 24 hour or 12 hour time according
- * to the conventions of the locale, and also includes am/pm markers where
+ * to the conventions of the locale, and also includes am/pm markers where 
  * appropriate. So it is preferable to use the skeletons.
  *
  * The following characters are available in explicit patterns:
@@ -637,6 +637,17 @@
   DateSymbols get dateSymbols => dateTimeSymbols[_locale];
 
   /**
+   * Set the locale. If the locale can't be found, we also look up
+   * based on alternative versions, e.g. if we have no 'en_CA' we will
+   * look for 'en' as a fallback. It will also translate en-ca into en_CA.
+   * Null is also considered a valid value for [newLocale], indicating
+   * to use the default.
+   */
+  _setLocale(String newLocale) {
+    _locale = Intl.verifiedLocale(newLocale, localeExists);
+  }
+
+  /**
    * Return true if the locale exists, or if it is null. The null case
    * is interpreted to mean that we use the default locale.
    */
@@ -679,6 +690,5 @@
         return _fieldConstructors[i](match.group(0), this);
       }
     }
-    return null;
   }
 }
diff --git a/lib/src/intl/date_format_field.dart b/lib/src/intl/date_format_field.dart
index dfa2447..d09f2c3 100644
--- a/lib/src/intl/date_format_field.dart
+++ b/lib/src/intl/date_format_field.dart
@@ -478,7 +478,7 @@
 
   String formatAmPm(DateTime date) {
     var hours = date.hour;
-    var index = (hours >= 12) && (hours < 24) ? 1 : 0;
+    var index = (date.hour >= 12) && (date.hour < 24) ? 1 : 0;
     var ampm = symbols.AMPMS;
     return ampm[index];
   }
diff --git a/lib/src/intl/number_format.dart b/lib/src/intl/number_format.dart
index c0e77a5..9e0de51 100644
--- a/lib/src/intl/number_format.dart
+++ b/lib/src/intl/number_format.dart
@@ -216,6 +216,7 @@
     var exponent = (log(number) / log(10)).floor();
     var mantissa = number / pow(10.0, exponent);
 
+    var minIntDigits = minimumIntegerDigits;
     if (maximumIntegerDigits > 1 &&
         maximumIntegerDigits > minimumIntegerDigits) {
       // A repeating range is defined; adjust to it as follows.
@@ -227,6 +228,7 @@
         mantissa *= 10;
         exponent--;
       }
+      minIntDigits = 1;
     } else {
       // No repeating range is defined, use minimum integer digits.
       if (minimumIntegerDigits < 1) {
@@ -398,6 +400,9 @@
   void _add(String x) {
     _buffer.write(x);
   }
+  void _addCharCode(int x) {
+    _buffer.writeCharCode(x);
+  }
   void _addZero() {
     _buffer.write(symbols.ZERO_DIGIT);
   }
diff --git a/test/bidi_utils_test.dart b/test/bidi_utils_test.dart
index 23ac723..b5b4fe5 100644
--- a/test/bidi_utils_test.dart
+++ b/test/bidi_utils_test.dart
@@ -314,13 +314,13 @@
     for (var i = 0; i < bidiText.length; i++) {
       var isRtlDir = Bidi.detectRtlDirectionality(bidiText[i].text,
           isHtml: bidiText[i].isHtml);
-
       if (isRtlDir != bidiText[i].isRtl) {
         var str = '"${bidiText[i].text} " should be '
             '${bidiText[i].isRtl ? "rtl" : "ltr"} but detected as '
             '${isRtlDir ? "rtl" : "ltr"}';
-        fail(str);
+        //alert(str);
       }
+      expect(bidiText[i].isRtl, isRtlDir);
     }
   });
 }