Version 3.18.1
Show:

File: date/js/date-parse.js

            /**
             * 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 {
                        Y.log("Could not convert data " + Y.dump(val) + " to type Date", "warn", "date");
                        return null;
                    }
                }
            });
            
            // Add Parsers shortcut
            Y.namespace("Parsers").date = Y.Date.parse;
            
            Y.namespace("DataType");
            Y.DataType.Date = Y.Date;