app/assets/javascripts/i18n.js in i18n-js-3.2.1 vs app/assets/javascripts/i18n.js in i18n-js-3.2.2

- old
+ new

@@ -613,11 +613,11 @@ return translation; }; // This function interpolates the all variables in the given message. I18n.interpolate = function(message, options) { - if (message === null) { + if (message == null) { return message; } options = options || {}; var matches = message.match(this.placeholder) @@ -831,12 +831,16 @@ // yyyy-mm-dd[ T]hh:mm::ss+00:00 // yyyy-mm-dd[ T]hh:mm::ss.123Z // I18n.parseDate = function(date) { var matches, convertedDate, fraction; + // A date input of `null` or `undefined` will be returned as-is + if (date == null) { + return date; + } // we have a date, so just return it. - if (typeof(date) == "object") { + if (typeof(date) === "object") { return date; } matches = date.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2})([\.,]\d{1,3})?)?(Z|\+00:?00)?/); @@ -978,15 +982,21 @@ I18n.toTime = function(scope, dateString) { var date = this.parseDate(dateString) , format = this.lookup(scope) ; - if (date.toString().match(/invalid/i)) { - return date.toString(); + // A date input of `null` or `undefined` will be returned as-is + if (date == null) { + return date; } + var date_string = date.toString() + if (date_string.match(/invalid/i)) { + return date_string; + } + if (!format) { - return date.toString(); + return date_string; } return this.strftime(date, format); };