Permalink
Browse files

Merge branch 'bug_2530058-fix-datatype-date-parse' of https://github.…

…com/curtisharvey/yui3 into date-parse-fix
  • Loading branch information...
2 parents 38c2823 + 2f9b8a3 commit e67ec9129e5d566ab9e211da0092e21e8b2bbcd6 @allenrabinovich committed Nov 8, 2012

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -300,4 +300,87 @@ Y.namespace("DataType");
Y.DataType.Date = Y.Date;
-}, '@VERSION@', {"lang": ["ar", "ar-JO", "ca", "ca-ES", "da", "da-DK", "de", "de-AT", "de-DE", "el", "el-GR", "en", "en-AU", "en-CA", "en-GB", "en-IE", "en-IN", "en-JO", "en-MY", "en-NZ", "en-PH", "en-SG", "en-US", "es", "es-AR", "es-BO", "es-CL", "es-CO", "es-EC", "es-ES", "es-MX", "es-PE", "es-PY", "es-US", "es-UY", "es-VE", "fi", "fi-FI", "fr", "fr-BE", "fr-CA", "fr-FR", "hi", "hi-IN", "id", "id-ID", "it", "it-IT", "ja", "ja-JP", "ko", "ko-KR", "ms", "ms-MY", "nb", "nb-NO", "nl", "nl-BE", "nl-NL", "pl", "pl-PL", "pt", "pt-BR", "ro", "ro-RO", "ru", "ru-RU", "sv", "sv-SE", "th", "th-TH", "tr", "tr-TR", "vi", "vi-VN", "zh-Hans", "zh-Hans-CN", "zh-Hant", "zh-Hant-HK", "zh-Hant-TW"]});
+}, '@VERSION@', {
+ "lang": [
+ "ar",
+ "ar-JO",
+ "ca",
+ "ca-ES",
+ "da",
+ "da-DK",
+ "de",
+ "de-AT",
+ "de-DE",
+ "el",
+ "el-GR",
+ "en",
+ "en-AU",
+ "en-CA",
+ "en-GB",
+ "en-IE",
+ "en-IN",
+ "en-JO",
+ "en-MY",
+ "en-NZ",
+ "en-PH",
+ "en-SG",
+ "en-US",
+ "es",
+ "es-AR",
+ "es-BO",
+ "es-CL",
+ "es-CO",
+ "es-EC",
+ "es-ES",
+ "es-MX",
+ "es-PE",
+ "es-PY",
+ "es-US",
+ "es-UY",
+ "es-VE",
+ "fi",
+ "fi-FI",
+ "fr",
+ "fr-BE",
+ "fr-CA",
+ "fr-FR",
+ "hi",
+ "hi-IN",
+ "id",
+ "id-ID",
+ "it",
+ "it-IT",
+ "ja",
+ "ja-JP",
+ "ko",
+ "ko-KR",
+ "ms",
+ "ms-MY",
+ "nb",
+ "nb-NO",
+ "nl",
+ "nl-BE",
+ "nl-NL",
+ "pl",
+ "pl-PL",
+ "pt",
+ "pt-BR",
+ "ro",
+ "ro-RO",
+ "ru",
+ "ru-RU",
+ "sv",
+ "sv-SE",
+ "th",
+ "th-TH",
+ "tr",
+ "tr-TR",
+ "vi",
+ "vi-VN",
+ "zh-Hans",
+ "zh-Hans-CN",
+ "zh-Hant",
+ "zh-Hant-HK",
+ "zh-Hant-TW"
+ ]
+});
@@ -298,4 +298,87 @@ Y.namespace("DataType");
Y.DataType.Date = Y.Date;
-}, '@VERSION@', {"lang": ["ar", "ar-JO", "ca", "ca-ES", "da", "da-DK", "de", "de-AT", "de-DE", "el", "el-GR", "en", "en-AU", "en-CA", "en-GB", "en-IE", "en-IN", "en-JO", "en-MY", "en-NZ", "en-PH", "en-SG", "en-US", "es", "es-AR", "es-BO", "es-CL", "es-CO", "es-EC", "es-ES", "es-MX", "es-PE", "es-PY", "es-US", "es-UY", "es-VE", "fi", "fi-FI", "fr", "fr-BE", "fr-CA", "fr-FR", "hi", "hi-IN", "id", "id-ID", "it", "it-IT", "ja", "ja-JP", "ko", "ko-KR", "ms", "ms-MY", "nb", "nb-NO", "nl", "nl-BE", "nl-NL", "pl", "pl-PL", "pt", "pt-BR", "ro", "ro-RO", "ru", "ru-RU", "sv", "sv-SE", "th", "th-TH", "tr", "tr-TR", "vi", "vi-VN", "zh-Hans", "zh-Hans-CN", "zh-Hant", "zh-Hant-HK", "zh-Hant-TW"]});
+}, '@VERSION@', {
+ "lang": [
+ "ar",
+ "ar-JO",
+ "ca",
+ "ca-ES",
+ "da",
+ "da-DK",
+ "de",
+ "de-AT",
+ "de-DE",
+ "el",
+ "el-GR",
+ "en",
+ "en-AU",
+ "en-CA",
+ "en-GB",
+ "en-IE",
+ "en-IN",
+ "en-JO",
+ "en-MY",
+ "en-NZ",
+ "en-PH",
+ "en-SG",
+ "en-US",
+ "es",
+ "es-AR",
+ "es-BO",
+ "es-CL",
+ "es-CO",
+ "es-EC",
+ "es-ES",
+ "es-MX",
+ "es-PE",
+ "es-PY",
+ "es-US",
+ "es-UY",
+ "es-VE",
+ "fi",
+ "fi-FI",
+ "fr",
+ "fr-BE",
+ "fr-CA",
+ "fr-FR",
+ "hi",
+ "hi-IN",
+ "id",
+ "id-ID",
+ "it",
+ "it-IT",
+ "ja",
+ "ja-JP",
+ "ko",
+ "ko-KR",
+ "ms",
+ "ms-MY",
+ "nb",
+ "nb-NO",
+ "nl",
+ "nl-BE",
+ "nl-NL",
+ "pl",
+ "pl-PL",
+ "pt",
+ "pt-BR",
+ "ro",
+ "ro-RO",
+ "ru",
+ "ru-RU",
+ "sv",
+ "sv-SE",
+ "th",
+ "th-TH",
+ "tr",
+ "tr-TR",
+ "vi",
+ "vi-VN",
+ "zh-Hans",
+ "zh-Hans-CN",
+ "zh-Hant",
+ "zh-Hant-HK",
+ "zh-Hant-TW"
+ ]
+});
@@ -26,10 +26,10 @@ _yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"] = {
path: "build/datatype-date-parse/datatype-date-parse.js",
code: []
};
-_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].code=["YUI.add('datatype-date-parse', function (Y, NAME) {","","/**"," * Parse number submodule."," *"," * @module datatype-date"," * @submodule datatype-date-parse"," * @for Date"," */","var LANG = Y.Lang;","","Y.mix(Y.namespace(\"Date\"), {"," /**"," * Converts data to type Date."," *"," * @method parse"," * @param data {String | Number} Data to convert. Values supported by the Date constructor are supported."," * @return {Date} A Date, or null."," */"," parse: function(data) {"," var date = null;",""," //Convert to date"," if(!(LANG.isDate(data))) {"," date = new Date(data);"," }"," else {"," return date;"," }",""," // Validate"," if(LANG.isDate(date) && (date != \"Invalid Date\") && !isNaN(date)) { // Workaround for bug 2527965"," return date;"," }"," else {"," return null;"," }"," }","});","","// Add Parsers shortcut","Y.namespace(\"Parsers\").date = Y.Date.parse;","","Y.namespace(\"DataType\");","Y.DataType.Date = Y.Date;","","","}, '@VERSION@');"];
-_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].lines = {"1":0,"10":0,"12":0,"21":0,"24":0,"25":0,"28":0,"32":0,"33":0,"36":0,"42":0,"44":0,"45":0};
-_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].functions = {"parse:20":0,"(anonymous 1):1":0};
-_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].coveredLines = 13;
+_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].code=["YUI.add('datatype-date-parse', function (Y, NAME) {","","/**"," * Parse number submodule."," *"," * @module datatype-date"," * @submodule datatype-date-parse"," * @for Date"," */","Y.mix(Y.namespace(\"Date\"), {"," /**"," * Converts data to type Date."," *"," * @method parse"," * @param data {Date|Number|String} date object, timestamp (string or number), or string parsable by Date.parse"," * @return {Date} a Date object or null if unable to parse"," */"," parse: function(data) {"," var val = new Date(+data || data);"," if (Y.Lang.isDate(val)) {"," return val;"," } else {"," return null;"," }"," }","});","","// Add Parsers shortcut","Y.namespace(\"Parsers\").date = Y.Date.parse;","","Y.namespace(\"DataType\");","Y.DataType.Date = Y.Date;","","","}, '@VERSION@');"];
+_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].lines = {"1":0,"10":0,"19":0,"20":0,"21":0,"23":0,"29":0,"31":0,"32":0};
+_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].functions = {"parse:18":0,"(anonymous 1):1":0};
+_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].coveredLines = 9;
_yuitest_coverage["build/datatype-date-parse/datatype-date-parse.js"].coveredFunctions = 2;
_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 1);
YUI.add('datatype-date-parse', function (Y, NAME) {
@@ -43,53 +43,36 @@ YUI.add('datatype-date-parse', function (Y, NAME) {
*/
_yuitest_coverfunc("build/datatype-date-parse/datatype-date-parse.js", "(anonymous 1)", 1);
_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 10);
-var LANG = Y.Lang;
-
-_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 12);
Y.mix(Y.namespace("Date"), {
/**
* Converts data to type Date.
*
* @method parse
- * @param data {String | Number} Data to convert. Values supported by the Date constructor are supported.
- * @return {Date} A Date, or null.
+ * @param data {Date|Number|String} date object, timestamp (string or number), or string parsable by Date.parse
+ * @return {Date} a Date object or null if unable to parse
*/
parse: function(data) {
- _yuitest_coverfunc("build/datatype-date-parse/datatype-date-parse.js", "parse", 20);
-_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 21);
-var date = null;
-
- //Convert to date
- _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 24);
-if(!(LANG.isDate(data))) {
- _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 25);
-date = new Date(data);
- }
- else {
- _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 28);
-return date;
- }
-
- // Validate
- _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 32);
-if(LANG.isDate(date) && (date != "Invalid Date") && !isNaN(date)) { // Workaround for bug 2527965
- _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 33);
-return date;
- }
- else {
- _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 36);
+ _yuitest_coverfunc("build/datatype-date-parse/datatype-date-parse.js", "parse", 18);
+_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 19);
+var val = new Date(+data || data);
+ _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 20);
+if (Y.Lang.isDate(val)) {
+ _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 21);
+return val;
+ } else {
+ _yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 23);
return null;
}
}
});
// Add Parsers shortcut
-_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 42);
+_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 29);
Y.namespace("Parsers").date = Y.Date.parse;
-_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 44);
+_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 31);
Y.namespace("DataType");
-_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 45);
+_yuitest_coverline("build/datatype-date-parse/datatype-date-parse.js", 32);
Y.DataType.Date = Y.Date;
@@ -7,33 +7,20 @@ YUI.add('datatype-date-parse', function (Y, NAME) {
* @submodule datatype-date-parse
* @for Date
*/
-var LANG = Y.Lang;
-
Y.mix(Y.namespace("Date"), {
/**
* Converts data to type Date.
*
* @method parse
- * @param data {String | Number} Data to convert. Values supported by the Date constructor are supported.
- * @return {Date} A Date, or null.
+ * @param data {Date|Number|String} date object, timestamp (string or number), or string parsable by Date.parse
+ * @return {Date} a Date object or null if unable to parse
*/
parse: function(data) {
- var date = null;
-
- //Convert to date
- if(!(LANG.isDate(data))) {
- date = new Date(data);
- }
- else {
- return date;
- }
-
- // Validate
- if(LANG.isDate(date) && (date != "Invalid Date") && !isNaN(date)) { // Workaround for bug 2527965
- return date;
- }
- else {
- Y.log("Could not convert data to type Date", "warn", "date");
+ var val = new Date(+data || data);
+ if (Y.Lang.isDate(val)) {
+ return val;
+ } else {
+ Y.log("Could not convert data " + Y.dump(val) + " to type Date", "warn", "date");
return null;
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -7,32 +7,19 @@ YUI.add('datatype-date-parse', function (Y, NAME) {
* @submodule datatype-date-parse
* @for Date
*/
-var LANG = Y.Lang;
-
Y.mix(Y.namespace("Date"), {
/**
* Converts data to type Date.
*
* @method parse
- * @param data {String | Number} Data to convert. Values supported by the Date constructor are supported.
- * @return {Date} A Date, or null.
+ * @param data {Date|Number|String} date object, timestamp (string or number), or string parsable by Date.parse
+ * @return {Date} a Date object or null if unable to parse
*/
parse: function(data) {
- var date = null;
-
- //Convert to date
- if(!(LANG.isDate(data))) {
- date = new Date(data);
- }
- else {
- return date;
- }
-
- // Validate
- if(LANG.isDate(date) && (date != "Invalid Date") && !isNaN(date)) { // Workaround for bug 2527965
- return date;
- }
- else {
+ var val = new Date(+data || data);
+ if (Y.Lang.isDate(val)) {
+ return val;
+ } else {
return null;
}
}
View
@@ -5,33 +5,20 @@
* @submodule datatype-date-parse
* @for Date
*/
-var LANG = Y.Lang;
-
Y.mix(Y.namespace("Date"), {
/**
* Converts data to type Date.
*
* @method parse
- * @param data {String | Number} Data to convert. Values supported by the Date constructor are supported.
- * @return {Date} A Date, or null.
+ * @param data {Date|Number|String} date object, timestamp (string or number), or string parsable by Date.parse
+ * @return {Date} a Date object or null if unable to parse
*/
parse: function(data) {
- var date = null;
-
- //Convert to date
- if(!(LANG.isDate(data))) {
- date = new Date(data);
- }
- else {
- return date;
- }
-
- // Validate
- if(LANG.isDate(date) && (date != "Invalid Date") && !isNaN(date)) { // Workaround for bug 2527965
- return date;
- }
- else {
- Y.log("Could not convert data to type Date", "warn", "date");
+ var val = new Date(+data || data);
+ if (Y.Lang.isDate(val)) {
+ return val;
+ } else {
+ Y.log("Could not convert data " + Y.dump(val) + " to type Date", "warn", "date");
return null;
}
}
Oops, something went wrong.

0 comments on commit e67ec91

Please sign in to comment.