Ignore:
Timestamp:
08/31/12 18:00:30 (12 years ago)
Author:
antonio
Message:

Ticket #3085 - Corrigida inconsistência com o formato de hora no Expresso Calendar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/plugins/datejs/parser-debug.js

    r5341 r7143  
    11/** 
    2  * Version: 1.0 Alpha-1  
    3  * Build Date: 12-Nov-2007 
    4  * Copyright (c) 2006-2007, Coolite Inc. (http://www.coolite.com/). All rights reserved. 
    5  * License: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/.  
    6  * Website: http://www.datejs.com/ or http://www.coolite.com/datejs/ 
     2 * @version: 1.0 Alpha-1 
     3 * @author: Coolite Inc. http://www.coolite.com/ 
     4 * @date: 2008-04-13 
     5 * @copyright: Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). All rights reserved. 
     6 * @license: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/.  
     7 * @website: http://www.datejs.com/ 
    78 */ 
    89  
    910(function () { 
    1011    Date.Parsing = { 
    11         Exception: function (s) {  
     12        Exception: function (s) { 
    1213            this.message = "Parse error at '" + s.substring(0, 10) + " ...'";  
    1314        } 
     
    465466 
    466467(function () { 
     468    var $D = Date, $P = $D.prototype, $C = $D.CultureInfo; 
     469 
    467470    var flattenAndCompact = function (ax) {  
    468471        var rx = [];  
     
    479482    }; 
    480483     
    481     Date.Grammar = {}; 
     484    $D.Grammar = {}; 
    482485         
    483     Date.Translator = { 
     486    $D.Translator = { 
    484487        hour: function (s) {  
    485488            return function () {  
     
    520523        month: function (s) { 
    521524            return function () { 
    522                 this.month = ((s.length == 3) ? Date.getMonthNumberFromName(s) : (Number(s) - 1)); 
     525                this.month = (s.length == 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s)/4 : Number(s) - 1; 
    523526            }; 
    524527        }, 
     
    527530                var n = Number(s); 
    528531                this.year = ((s.length > 2) ? n :  
    529                     (n + (((n + 2000) < Date.CultureInfo.twoDigitYearMax) ? 2000 : 1900)));  
     532                    (n + (((n + 2000) < $C.twoDigitYearMax) ? 2000 : 1900)));  
    530533            }; 
    531534        }, 
     
    551554        finishExact: function (x) {   
    552555            x = (x instanceof Array) ? x : [ x ];  
    553                  
    554             var now = new Date(); 
    555  
    556             this.year = now.getFullYear();  
    557             this.month = now.getMonth();  
    558             this.day = 1;  
    559  
    560             this.hour = 0;  
    561             this.minute = 0;  
    562             this.second = 0; 
    563556 
    564557            for (var i = 0 ; i < x.length ; i++) {  
     
    566559                    x[i].call(this);  
    567560                } 
    568             }  
    569  
    570             this.hour = (this.meridian == "p" && this.hour < 13) ? this.hour + 12 : this.hour; 
    571  
    572             if (this.day > Date.getDaysInMonth(this.year, this.month)) { 
     561            } 
     562             
     563            var now = new Date(); 
     564             
     565            if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { 
     566                this.day = now.getDate(); 
     567            } 
     568 
     569            if (!this.year) { 
     570                this.year = now.getFullYear(); 
     571            } 
     572             
     573            if (!this.month && this.month !== 0) { 
     574                this.month = now.getMonth(); 
     575            } 
     576             
     577            if (!this.day) { 
     578                this.day = 1; 
     579            } 
     580             
     581            if (!this.hour) { 
     582                this.hour = 0; 
     583            } 
     584             
     585            if (!this.minute) { 
     586                this.minute = 0; 
     587            } 
     588 
     589            if (!this.second) { 
     590                this.second = 0; 
     591            } 
     592 
     593            if (this.meridian && this.hour) { 
     594                if (this.meridian == "p" && this.hour < 12) { 
     595                    this.hour = this.hour + 12; 
     596                } else if (this.meridian == "a" && this.hour == 12) { 
     597                    this.hour = 0; 
     598                } 
     599            } 
     600             
     601            if (this.day > $D.getDaysInMonth(this.year, this.month)) { 
    573602                throw new RangeError(this.day + " is not a valid value for days."); 
    574603            } 
     
    581610                r.set({ timezoneOffset: this.timezoneOffset });  
    582611            } 
     612             
    583613            return r; 
    584614        },                       
     
    595625                } 
    596626            } 
    597  
    598             if (this.now) {  
     627             
     628            var today = $D.today(); 
     629             
     630            if (this.now && !this.unit && !this.operator) {  
    599631                return new Date();  
    600             } 
    601  
    602             var today = Date.today();  
    603             var method = null; 
    604  
    605             var expression = !!(this.days != null || this.orient || this.operator); 
    606             if (expression) { 
    607                 var gap, mod, orient; 
    608                 orient = ((this.orient == "past" || this.operator == "subtract") ? -1 : 1); 
    609  
    610                 if (this.weekday) { 
    611                     this.unit = "day"; 
    612                     gap = (Date.getDayNumberFromName(this.weekday) - today.getDay()); 
    613                     mod = 7; 
    614                     this.days = gap ? ((gap + (orient * mod)) % mod) : (orient * mod); 
    615                 } 
    616                 if (this.month) { 
    617                     this.unit = "month"; 
    618                     gap = (this.month - today.getMonth()); 
    619                     mod = 12; 
    620                     this.months = gap ? ((gap + (orient * mod)) % mod) : (orient * mod); 
     632            } else if (this.now) { 
     633                today = new Date(); 
     634            } 
     635             
     636            var expression = !!(this.days && this.days !== null || this.orient || this.operator); 
     637             
     638            var gap, mod, orient; 
     639            orient = ((this.orient == "past" || this.operator == "subtract") ? -1 : 1); 
     640             
     641            if(!this.now && "hour minute second".indexOf(this.unit) != -1) { 
     642                today.setTimeToNow(); 
     643            } 
     644 
     645            if (this.month || this.month === 0) { 
     646                if ("year day hour minute second".indexOf(this.unit) != -1) { 
     647                    this.value = this.month + 1; 
    621648                    this.month = null; 
    622                 } 
    623                 if (!this.unit) {  
    624                     this.unit = "day";  
    625                 } 
    626                 if (this[this.unit + "s"] == null || this.operator != null) { 
    627                     if (!this.value) {  
    628                         this.value = 1; 
    629                     } 
    630  
    631                     if (this.unit == "week") {  
    632                         this.unit = "day";  
    633                         this.value = this.value * 7;  
    634                     } 
    635  
    636                     this[this.unit + "s"] = this.value * orient; 
    637                 } 
    638                 return today.add(this); 
    639             } else { 
    640                 if (this.meridian && this.hour) { 
    641                     this.hour = (this.hour < 13 && this.meridian == "p") ? this.hour + 12 : this.hour;                   
    642                 } 
    643                 if (this.weekday && !this.day) { 
    644                     this.day = (today.addDays((Date.getDayNumberFromName(this.weekday) - today.getDay()))).getDate(); 
    645                 } 
    646                 if (this.month && !this.day) {  
    647                     this.day = 1;  
    648                 } 
    649                 return today.set(this); 
    650             } 
    651         } 
    652     }; 
    653  
    654     var _ = Date.Parsing.Operators, g = Date.Grammar, t = Date.Translator, _fn; 
     649                    expression = true; 
     650                } 
     651            } 
     652             
     653            if (!expression && this.weekday && !this.day && !this.days) { 
     654                var temp = Date[this.weekday](); 
     655                this.day = temp.getDate(); 
     656                if (!this.month) { 
     657                    this.month = temp.getMonth(); 
     658                } 
     659                this.year = temp.getFullYear(); 
     660            } 
     661             
     662            if (expression && this.weekday && this.unit != "month") { 
     663                this.unit = "day"; 
     664                gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); 
     665                mod = 7; 
     666                this.days = gap ? ((gap + (orient * mod)) % mod) : (orient * mod); 
     667            } 
     668             
     669            if (this.month && this.unit == "day" && this.operator) { 
     670                this.value = (this.month + 1); 
     671                this.month = null; 
     672            } 
     673        
     674            if (this.value != null && this.month != null && this.year != null) { 
     675                this.day = this.value * 1; 
     676            } 
     677      
     678            if (this.month && !this.day && this.value) { 
     679                today.set({ day: this.value * 1 }); 
     680                if (!expression) { 
     681                    this.day = this.value * 1; 
     682                } 
     683            } 
     684 
     685            if (!this.month && this.value && this.unit == "month" && !this.now) { 
     686                this.month = this.value; 
     687                expression = true; 
     688            } 
     689 
     690            if (expression && (this.month || this.month === 0) && this.unit != "year") { 
     691                this.unit = "month"; 
     692                gap = (this.month - today.getMonth()); 
     693                mod = 12; 
     694                this.months = gap ? ((gap + (orient * mod)) % mod) : (orient * mod); 
     695                this.month = null; 
     696            } 
     697 
     698            if (!this.unit) {  
     699                this.unit = "day";  
     700            } 
     701             
     702            if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { 
     703                this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator == "add") ? 1 : -1) + (this.value||0) * orient; 
     704            } else if (this[this.unit + "s"] == null || this.operator != null) { 
     705                if (!this.value) { 
     706                    this.value = 1; 
     707                } 
     708                this[this.unit + "s"] = this.value * orient; 
     709            } 
     710 
     711            if (this.meridian && this.hour) { 
     712                if (this.meridian == "p" && this.hour < 12) { 
     713                    this.hour = this.hour + 12; 
     714                } else if (this.meridian == "a" && this.hour == 12) { 
     715                    this.hour = 0; 
     716                } 
     717            } 
     718             
     719            if (this.weekday && !this.day && !this.days) { 
     720                var temp = Date[this.weekday](); 
     721                this.day = temp.getDate(); 
     722                if (temp.getMonth() !== today.getMonth()) { 
     723                    this.month = temp.getMonth(); 
     724                } 
     725            } 
     726             
     727            if ((this.month || this.month === 0) && !this.day) {  
     728                this.day = 1;  
     729            } 
     730             
     731            if (!this.orient && !this.operator && this.unit == "week" && this.value && !this.day && !this.month) { 
     732                return Date.today().setWeek(this.value); 
     733            } 
     734 
     735            if (expression && this.timezone && this.day && this.days) { 
     736                this.day = this.days; 
     737            } 
     738             
     739            return (expression) ? today.add(this) : today.set(this); 
     740        } 
     741    }; 
     742 
     743    var _ = $D.Parsing.Operators, g = $D.Grammar, t = $D.Translator, _fn; 
    655744 
    656745    g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/);  
    657746    g.timePartDelimiter = _.stoken(":"); 
    658747    g.whiteSpace = _.rtoken(/^\s*/); 
    659     g.generalDelimiter = _.rtoken(/^(([\s\,]|at|on)+)/); 
     748    g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); 
    660749   
    661750    var _C = {}; 
     
    663752        var fn = _C[keys]; 
    664753        if (! fn) { 
    665             var c = Date.CultureInfo.regexPatterns; 
     754            var c = $C.regexPatterns; 
    666755            var kx = keys.split(/\s+/), px = [];  
    667756            for (var i = 0; i < kx.length ; i++) { 
     
    673762    }; 
    674763    g.ctoken2 = function (key) {  
    675         return _.rtoken(Date.CultureInfo.regexPatterns[key]); 
     764        return _.rtoken($C.regexPatterns[key]); 
    676765    }; 
    677766 
     
    685774    g.s = _.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/), t.second)); 
    686775    g.ss = _.cache(_.process(_.rtoken(/^[0-5][0-9]/), t.second)); 
    687     g.hms = _.cache(_.sequence([g.H, g.mm, g.ss], g.timePartDelimiter)); 
     776    g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); 
    688777   
    689778    // _.min(1, _.set([ g.H, g.m, g.s ], g._t)); 
    690779    g.t = _.cache(_.process(g.ctoken2("shortMeridian"), t.meridian)); 
    691780    g.tt = _.cache(_.process(g.ctoken2("longMeridian"), t.meridian)); 
    692     g.z = _.cache(_.process(_.rtoken(/^(\+|\-)?\s*\d\d\d\d?/), t.timezone)); 
    693     g.zz = _.cache(_.process(_.rtoken(/^(\+|\-)\s*\d\d\d\d/), t.timezone)); 
     781    g.z = _.cache(_.process(_.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/), t.timezone)); 
     782    g.zz = _.cache(_.process(_.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/), t.timezone)); 
     783     
    694784    g.zzz = _.cache(_.process(g.ctoken2("timezone"), t.timezone)); 
    695785    g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([ g.tt, g.zzz ])); 
    696786    g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); 
    697            
     787           
    698788    // days, months, years 
    699789    g.d = _.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1]|\d)/),  
     
    742832    );   
    743833    g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); 
    744     g.unit = _.process(g.ctoken("minute hour day week month year"),  
     834    g.unit = _.process(g.ctoken("second minute hour day week month year"),  
    745835        function (s) {  
    746836            return function () {  
     
    766856    g.dmy = _fn(g.ddd, g.day, g.month, g.year); 
    767857    g.date = function (s) {  
    768         return ((g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s)); 
     858        return ((g[$C.dateElementOrder] || g.mdy).call(this, s)); 
    769859    };  
    770860 
     
    781871            return g[fmt];  
    782872        } else {  
    783             throw Date.Parsing.Exception(fmt);  
     873            throw $D.Parsing.Exception(fmt);  
    784874        } 
    785875    } 
     
    830920        // check for these formats first 
    831921    g._formats = g.formats([ 
     922        "\"yyyy-MM-ddTHH:mm:ssZ\"", 
     923        "yyyy-MM-ddTHH:mm:ssZ", 
     924        "yyyy-MM-ddTHH:mm:ssz", 
    832925        "yyyy-MM-ddTHH:mm:ss", 
     926        "yyyy-MM-ddTHH:mmZ", 
     927        "yyyy-MM-ddTHH:mmz", 
     928        "yyyy-MM-ddTHH:mm", 
    833929        "ddd, MMM dd, yyyy H:mm:ss tt", 
    834930        "ddd MMM d yyyy HH:mm:ss zzz", 
     931        "MMddyyyy", 
     932        "ddMMyyyy", 
     933        "Mddyyyy", 
     934        "ddMyyyy", 
     935        "Mdyyyy", 
     936        "dMyyyy", 
     937        "yyyy", 
     938        "Mdyy", 
     939        "dMyy", 
    835940        "d" 
    836941    ]); 
     
    851956        return g._start.call({}, s); 
    852957    }; 
    853                  
    854 }()); 
    855  
    856  
    857 Date._parse = Date.parse; 
    858  
    859 /** 
    860  * Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. 
    861  *  
    862  * Example 
    863 <pre><code> 
    864 /////////// 
    865 // Dates // 
    866 /////////// 
    867  
    868 // 15-Oct-2004 
    869 var d1 = Date.parse("10/15/2004"); 
    870  
    871 // 15-Oct-2004 
    872 var d1 = Date.parse("15-Oct-2004"); 
    873  
    874 // 15-Oct-2004 
    875 var d1 = Date.parse("2004.10.15"); 
    876  
    877 //Fri Oct 15, 2004 
    878 var d1 = Date.parse("Fri Oct 15, 2004"); 
    879  
    880 /////////// 
    881 // Times // 
    882 /////////// 
    883  
    884 // Today at 10 PM. 
    885 var d1 = Date.parse("10 PM"); 
    886  
    887 // Today at 10:30 PM. 
    888 var d1 = Date.parse("10:30 P.M."); 
    889  
    890 // Today at 6 AM. 
    891 var d1 = Date.parse("06am"); 
    892  
    893 ///////////////////// 
    894 // Dates and Times // 
    895 ///////////////////// 
    896  
    897 // 8-July-2004 @ 10:30 PM 
    898 var d1 = Date.parse("July 8th, 2004, 10:30 PM"); 
    899  
    900 // 1-July-2004 @ 10:30 PM 
    901 var d1 = Date.parse("2004-07-01T22:30:00"); 
    902  
    903 //////////////////// 
    904 // Relative Dates // 
    905 //////////////////// 
    906  
    907 // Returns today's date. The string "today" is culture specific. 
    908 var d1 = Date.parse("today"); 
    909  
    910 // Returns yesterday's date. The string "yesterday" is culture specific. 
    911 var d1 = Date.parse("yesterday"); 
    912  
    913 // Returns the date of the next thursday. 
    914 var d1 = Date.parse("Next thursday"); 
    915  
    916 // Returns the date of the most previous monday. 
    917 var d1 = Date.parse("last monday"); 
    918  
    919 // Returns today's day + one year. 
    920 var d1 = Date.parse("next year"); 
    921  
    922 /////////////// 
    923 // Date Math // 
    924 /////////////// 
    925  
    926 // Today + 2 days 
    927 var d1 = Date.parse("t+2"); 
    928  
    929 // Today + 2 days 
    930 var d1 = Date.parse("today + 2 days"); 
    931  
    932 // Today + 3 months 
    933 var d1 = Date.parse("t+3m"); 
    934  
    935 // Today - 1 year 
    936 var d1 = Date.parse("today - 1 year"); 
    937  
    938 // Today - 1 year 
    939 var d1 = Date.parse("t-1y");  
    940  
    941  
    942 ///////////////////////////// 
    943 // Partial Dates and Times // 
    944 ///////////////////////////// 
    945  
    946 // July 15th of this year. 
    947 var d1 = Date.parse("July 15"); 
    948  
    949 // 15th day of current day and year. 
    950 var d1 = Date.parse("15"); 
    951  
    952 // July 1st of current year at 10pm. 
    953 var d1 = Date.parse("7/1 10pm"); 
    954 </code></pre> 
    955  * 
    956  * @param {String}   The string value to convert into a Date object [Required] 
    957  * @return {Date}    A Date object or null if the string cannot be converted into a Date. 
    958  */ 
    959 Date.parse = function (s) { 
    960     var r = null;  
    961     if (!s) {  
    962         return null;  
    963     } 
    964     try {  
    965         r = Date.Grammar.start.call({}, s);  
    966     } catch (e) {  
    967         return null;  
    968     } 
    969     return ((r[1].length === 0) ? r[0] : null); 
    970 }; 
    971  
    972 Date.getParseFunction = function (fx) { 
    973     var fn = Date.Grammar.formats(fx); 
    974     return function (s) { 
    975         var r = null; 
     958         
     959        $D._parse = $D.parse; 
     960 
     961    /** 
     962     * Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. 
     963     *  
     964     * Example 
     965    <pre><code> 
     966    /////////// 
     967    // Dates // 
     968    /////////// 
     969 
     970    // 15-Oct-2004 
     971    var d1 = Date.parse("10/15/2004"); 
     972 
     973    // 15-Oct-2004 
     974    var d1 = Date.parse("15-Oct-2004"); 
     975 
     976    // 15-Oct-2004 
     977    var d1 = Date.parse("2004.10.15"); 
     978 
     979    //Fri Oct 15, 2004 
     980    var d1 = Date.parse("Fri Oct 15, 2004"); 
     981 
     982    /////////// 
     983    // Times // 
     984    /////////// 
     985 
     986    // Today at 10 PM. 
     987    var d1 = Date.parse("10 PM"); 
     988 
     989    // Today at 10:30 PM. 
     990    var d1 = Date.parse("10:30 P.M."); 
     991 
     992    // Today at 6 AM. 
     993    var d1 = Date.parse("06am"); 
     994 
     995    ///////////////////// 
     996    // Dates and Times // 
     997    ///////////////////// 
     998 
     999    // 8-July-2004 @ 10:30 PM 
     1000    var d1 = Date.parse("July 8th, 2004, 10:30 PM"); 
     1001 
     1002    // 1-July-2004 @ 10:30 PM 
     1003    var d1 = Date.parse("2004-07-01T22:30:00"); 
     1004 
     1005    //////////////////// 
     1006    // Relative Dates // 
     1007    //////////////////// 
     1008 
     1009    // Returns today's date. The string "today" is culture specific. 
     1010    var d1 = Date.parse("today"); 
     1011 
     1012    // Returns yesterday's date. The string "yesterday" is culture specific. 
     1013    var d1 = Date.parse("yesterday"); 
     1014 
     1015    // Returns the date of the next thursday. 
     1016    var d1 = Date.parse("Next thursday"); 
     1017 
     1018    // Returns the date of the most previous monday. 
     1019    var d1 = Date.parse("last monday"); 
     1020 
     1021    // Returns today's day + one year. 
     1022    var d1 = Date.parse("next year"); 
     1023 
     1024    /////////////// 
     1025    // Date Math // 
     1026    /////////////// 
     1027 
     1028    // Today + 2 days 
     1029    var d1 = Date.parse("t+2"); 
     1030 
     1031    // Today + 2 days 
     1032    var d1 = Date.parse("today + 2 days"); 
     1033 
     1034    // Today + 3 months 
     1035    var d1 = Date.parse("t+3m"); 
     1036 
     1037    // Today - 1 year 
     1038    var d1 = Date.parse("today - 1 year"); 
     1039 
     1040    // Today - 1 year 
     1041    var d1 = Date.parse("t-1y");  
     1042 
     1043 
     1044    ///////////////////////////// 
     1045    // Partial Dates and Times // 
     1046    ///////////////////////////// 
     1047 
     1048    // July 15th of this year. 
     1049    var d1 = Date.parse("July 15"); 
     1050 
     1051    // 15th day of current day and year. 
     1052    var d1 = Date.parse("15"); 
     1053 
     1054    // July 1st of current year at 10pm. 
     1055    var d1 = Date.parse("7/1 10pm"); 
     1056    </code></pre> 
     1057     * 
     1058     * @param {String}   The string value to convert into a Date object [Required] 
     1059     * @return {Date}    A Date object or null if the string cannot be converted into a Date. 
     1060     */ 
     1061    $D.parse = function (s) { 
     1062        var r = null;  
     1063        if (!s) {  
     1064            return null;  
     1065        } 
     1066        if (s instanceof Date) { 
     1067            return s; 
     1068        } 
    9761069        try {  
    977             r = fn.call({}, s);  
     1070            r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"));  
    9781071        } catch (e) {  
    9791072            return null;  
     
    9811074        return ((r[1].length === 0) ? r[0] : null); 
    9821075    }; 
    983 }; 
    984 /** 
    985  * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. 
    986  * The format of the string value must match one of the supplied formats exactly. 
    987  *  
    988  * Example 
    989 <pre><code> 
    990 // 15-Oct-2004 
    991 var d1 = Date.parseExact("10/15/2004", "M/d/yyyy"); 
    992  
    993 // 15-Oct-2004 
    994 var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy"); 
    995  
    996 // 15-Oct-2004 
    997 var d1 = Date.parse("2004.10.15", "yyyy.MM.dd"); 
    998  
    999 // Multiple formats 
    1000 var d1 = Date.parseExact("10/15/2004", [ "M/d/yyyy" , "MMMM d, yyyy" ]); 
    1001 </code></pre> 
    1002  * 
    1003  * @param {String}   The string value to convert into a Date object [Required]. 
    1004  * @param {Object}   The expected format {String} or an array of expected formats {Array} of the date string [Required]. 
    1005  * @return {Date}    A Date object or null if the string cannot be converted into a Date. 
    1006  */ 
    1007 Date.parseExact = function (s, fx) {  
    1008     return Date.getParseFunction(fx)(s);  
    1009 }; 
     1076 
     1077    $D.getParseFunction = function (fx) { 
     1078        var fn = $D.Grammar.formats(fx); 
     1079        return function (s) { 
     1080            var r = null; 
     1081            try {  
     1082                r = fn.call({}, s);  
     1083            } catch (e) {  
     1084                return null;  
     1085            } 
     1086            return ((r[1].length === 0) ? r[0] : null); 
     1087        }; 
     1088    }; 
     1089     
     1090    /** 
     1091     * Converts the specified string value into its JavaScript Date equivalent using the specified format {String} or formats {Array} and the CultureInfo specific format information. 
     1092     * The format of the string value must match one of the supplied formats exactly. 
     1093     *  
     1094     * Example 
     1095    <pre><code> 
     1096    // 15-Oct-2004 
     1097    var d1 = Date.parseExact("10/15/2004", "M/d/yyyy"); 
     1098 
     1099    // 15-Oct-2004 
     1100    var d1 = Date.parse("15-Oct-2004", "M-ddd-yyyy"); 
     1101 
     1102    // 15-Oct-2004 
     1103    var d1 = Date.parse("2004.10.15", "yyyy.MM.dd"); 
     1104 
     1105    // Multiple formats 
     1106    var d1 = Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]); 
     1107    </code></pre> 
     1108     * 
     1109     * @param {String}   The string value to convert into a Date object [Required]. 
     1110     * @param {Object}   The expected format {String} or an array of expected formats {Array} of the date string [Required]. 
     1111     * @return {Date}    A Date object or null if the string cannot be converted into a Date. 
     1112     */ 
     1113    $D.parseExact = function (s, fx) {  
     1114        return $D.getParseFunction(fx)(s);  
     1115    };   
     1116}()); 
Note: See TracChangeset for help on using the changeset viewer.