]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/include/javascript/yui3/build/datatype/datatype.js
Release 6.2.0beta4
[Github/sugarcrm.git] / jssource / src_files / include / javascript / yui3 / build / datatype / datatype.js
1 /*
2 Copyright (c) 2009, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.net/yui/license.txt
5 version: 3.0.0
6 build: 1549
7 */
8 YUI.add('datatype-number-parse', function(Y) {
9
10 /**
11  * Parse number submodule.
12  *
13  * @module datatype
14  * @submodule datatype-number-parse
15  * @for DataType.Number
16  */
17
18 var LANG = Y.Lang;
19
20 Y.mix(Y.namespace("DataType.Number"), {
21     /**
22      * Converts data to type Number.
23      *
24      * @method parse
25      * @param data {String | Number | Boolean} Data to convert. The following
26      * values return as null: null, undefined, NaN, "".
27      * @return {Number} A number, or null.
28      */
29     parse: function(data) {
30         var number = (data === null) ? data : +data;
31         if(LANG.isNumber(number)) {
32             return number;
33         }
34         else {
35             return null;
36         }
37     }
38 });
39
40 // Add Parsers shortcut
41 Y.namespace("Parsers").number = Y.DataType.Number.parse;
42
43
44
45 }, '3.0.0' );
46
47 YUI.add('datatype-number-format', function(Y) {
48
49 /**
50  * Number submodule.
51  *
52  * @module datatype
53  * @submodule datatype-number
54  */
55
56 /**
57  * Format number submodule.
58  *
59  * @module datatype
60  * @submodule datatype-number-format
61  */
62  
63 /**
64  * DataType.Number provides a set of utility functions to operate against Number objects.
65  *
66  * @class DataType.Number
67  * @static
68  */
69 var LANG = Y.Lang;
70
71 Y.mix(Y.namespace("DataType.Number"), {
72      /**
73      * Takes a Number and formats to string for display to user.
74      *
75      * @method format
76      * @param data {Number} Number.
77      * @param config {Object} (Optional) Optional configuration values:
78      *  <dl>
79      *   <dt>prefix {String}</dd>
80      *   <dd>String prepended before each number, like a currency designator "$"</dd>
81      *   <dt>decimalPlaces {Number}</dd>
82      *   <dd>Number of decimal places to round. Must be a number 0 to 20.</dd>
83      *   <dt>decimalSeparator {String}</dd>
84      *   <dd>Decimal separator</dd>
85      *   <dt>thousandsSeparator {String}</dd>
86      *   <dd>Thousands separator</dd>
87      *   <dt>suffix {String}</dd>
88      *   <dd>String appended after each number, like " items" (note the space)</dd>
89      *  </dl>
90      * @return {String} Formatted number for display. Note, the following values
91      * return as "": null, undefined, NaN, "".
92      */
93     format: function(data, config) {
94         if(LANG.isNumber(data)) {
95             config = config || {};
96
97             var isNeg = (data < 0),
98                 output = data + "",
99                 decPlaces = config.decimalPlaces,
100                 decSep = config.decimalSeparator || ".",
101                 thouSep = config.thousandsSeparator,
102                 decIndex,
103                 newOutput, count, i;
104
105             // Decimal precision
106             if(LANG.isNumber(decPlaces) && (decPlaces >= 0) && (decPlaces <= 20)) {
107                 // Round to the correct decimal place
108                 output = data.toFixed(decPlaces);
109             }
110
111             // Decimal separator
112             if(decSep !== "."){
113                 output = output.replace(".", decSep);
114             }
115
116             // Add the thousands separator
117             if(thouSep) {
118                 // Find the dot or where it would be
119                 decIndex = output.lastIndexOf(decSep);
120                 decIndex = (decIndex > -1) ? decIndex : output.length;
121                 // Start with the dot and everything to the right
122                 newOutput = output.substring(decIndex);
123                 // Working left, every third time add a separator, every time add a digit
124                 for (count = 0, i=decIndex; i>0; i--) {
125                     if ((count%3 === 0) && (i !== decIndex) && (!isNeg || (i > 1))) {
126                         newOutput = thouSep + newOutput;
127                     }
128                     newOutput = output.charAt(i-1) + newOutput;
129                     count++;
130                 }
131                 output = newOutput;
132             }
133
134             // Prepend prefix
135             output = (config.prefix) ? config.prefix + output : output;
136
137             // Append suffix
138             output = (config.suffix) ? output + config.suffix : output;
139
140             return output;
141         }
142         // Not a Number, just return as string
143         else {
144             return (LANG.isValue(data) && data.toString) ? data.toString() : "";
145         }
146     }
147 });
148
149
150
151 }, '3.0.0' );
152
153
154
155 YUI.add('datatype-number', function(Y){}, '3.0.0' ,{use:['datatype-number-parse', 'datatype-number-format']});
156
157
158 YUI.add('datatype-date-parse', function(Y) {
159
160 /**
161  * Parse number submodule.
162  *
163  * @module datatype
164  * @submodule datatype-date-parse
165  * @for DataType.Date
166  */
167 var LANG = Y.Lang;
168
169 Y.mix(Y.namespace("DataType.Date"), {
170     /**
171      * Converts data to type Date.
172      *
173      * @method parse
174      * @param data {String | Number} Data to convert. Values supported by the Date constructor are supported.
175      * @return {Date} A Date, or null.
176      */
177     parse: function(data) {
178         var date = null;
179
180         //Convert to date
181         if(!(LANG.isDate(data))) {
182             date = new Date(data);
183         }
184         else {
185             return date;
186         }
187
188         // Validate
189         if(LANG.isDate(date) && (date != "Invalid Date") && !isNaN(date)) { // Workaround for bug 2527965
190             return date;
191         }
192         else {
193             return null;
194         }
195     }
196 });
197
198 // Add Parsers shortcut
199 Y.namespace("Parsers").date = Y.DataType.Date.parse;
200
201
202
203 }, '3.0.0' );
204
205 YUI.add('datatype-date-format', function(Y) {
206
207 /**
208  * The DataType Utility provides type-conversion and string-formatting
209  * convenience methods for various JavaScript object types.
210  *
211  * @module datatype
212  */
213
214 /**
215  * Date submodule.
216  *
217  * @module datatype
218  * @submodule datatype-date
219  */
220
221 /**
222  * Format date submodule implements strftime formatters for javascript based on the
223  * Open Group specification defined at
224  * http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html
225  * This implementation does not include modified conversion specifiers (i.e., Ex and Ox)
226  *
227  * @module datatype
228  * @submodule datatype-date-format
229  */
230
231 /**
232  * DataType.Date provides a set of utility functions to operate against Date objects.
233  *
234  * @class DataType.Date
235  * @static
236  */
237
238 /**
239  * Pad a number with leading spaces, zeroes or something else
240  * @method xPad
241  * @param x {Number}    The number to be padded
242  * @param pad {String}  The character to pad the number with
243  * @param r {Number}    (optional) The base of the pad, eg, 10 implies to two digits, 100 implies to 3 digits.
244  * @private
245  */
246 var xPad=function (x, pad, r)
247 {
248         if(typeof r === "undefined")
249         {
250                 r=10;
251         }
252         pad = pad.toString();
253         for( ; parseInt(x, 10)<r && r>1; r/=10) {
254                 x = pad + x;
255         }
256         return x.toString();
257 };
258
259 /**
260  * Default date format.
261  *
262  * @for config
263  * @property dateFormat
264  * @type String
265  * @value "%Y-%m-%d"
266  */
267 Y.config.dateFormat = Y.config.dateFormat || "%Y-%m-%d";
268
269 /**
270  * Default locale for the YUI instance.
271  *
272  * @property locale
273  * @type String
274  * @value "en"
275  */
276 Y.config.locale = Y.config.locale || "en";
277
278 var Dt = {
279         formats: {
280                 a: function (d, l) { return l.a[d.getDay()]; },
281                 A: function (d, l) { return l.A[d.getDay()]; },
282                 b: function (d, l) { return l.b[d.getMonth()]; },
283                 B: function (d, l) { return l.B[d.getMonth()]; },
284                 C: function (d) { return xPad(parseInt(d.getFullYear()/100, 10), 0); },
285                 d: ["getDate", "0"],
286                 e: ["getDate", " "],
287                 g: function (d) { return xPad(parseInt(Dt.formats.G(d)%100, 10), 0); },
288                 G: function (d) {
289                                 var y = d.getFullYear();
290                                 var V = parseInt(Dt.formats.V(d), 10);
291                                 var W = parseInt(Dt.formats.W(d), 10);
292         
293                                 if(W > V) {
294                                         y++;
295                                 } else if(W===0 && V>=52) {
296                                         y--;
297                                 }
298         
299                                 return y;
300                         },
301                 H: ["getHours", "0"],
302                 I: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, 0); },
303                 j: function (d) {
304                                 var gmd_1 = new Date("" + d.getFullYear() + "/1/1 GMT");
305                                 var gmdate = new Date("" + d.getFullYear() + "/" + (d.getMonth()+1) + "/" + d.getDate() + " GMT");
306                                 var ms = gmdate - gmd_1;
307                                 var doy = parseInt(ms/60000/60/24, 10)+1;
308                                 return xPad(doy, 0, 100);
309                         },
310                 k: ["getHours", " "],
311                 l: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, " "); },
312                 m: function (d) { return xPad(d.getMonth()+1, 0); },
313                 M: ["getMinutes", "0"],
314                 p: function (d, l) { return l.p[d.getHours() >= 12 ? 1 : 0 ]; },
315                 P: function (d, l) { return l.P[d.getHours() >= 12 ? 1 : 0 ]; },
316                 s: function (d, l) { return parseInt(d.getTime()/1000, 10); },
317                 S: ["getSeconds", "0"],
318                 u: function (d) { var dow = d.getDay(); return dow===0?7:dow; },
319                 U: function (d) {
320                                 var doy = parseInt(Dt.formats.j(d), 10);
321                                 var rdow = 6-d.getDay();
322                                 var woy = parseInt((doy+rdow)/7, 10);
323                                 return xPad(woy, 0);
324                         },
325                 V: function (d) {
326                                 var woy = parseInt(Dt.formats.W(d), 10);
327                                 var dow1_1 = (new Date("" + d.getFullYear() + "/1/1")).getDay();
328                                 // First week is 01 and not 00 as in the case of %U and %W,
329                                 // so we add 1 to the final result except if day 1 of the year
330                                 // is a Monday (then %W returns 01).
331                                 // We also need to subtract 1 if the day 1 of the year is 
332                                 // Friday-Sunday, so the resulting equation becomes:
333                                 var idow = woy + (dow1_1 > 4 || dow1_1 <= 1 ? 0 : 1);
334                                 if(idow === 53 && (new Date("" + d.getFullYear() + "/12/31")).getDay() < 4)
335                                 {
336                                         idow = 1;
337                                 }
338                                 else if(idow === 0)
339                                 {
340                                         idow = Dt.formats.V(new Date("" + (d.getFullYear()-1) + "/12/31"));
341                                 }
342         
343                                 return xPad(idow, 0);
344                         },
345                 w: "getDay",
346                 W: function (d) {
347                                 var doy = parseInt(Dt.formats.j(d), 10);
348                                 var rdow = 7-Dt.formats.u(d);
349                                 var woy = parseInt((doy+rdow)/7, 10);
350                                 return xPad(woy, 0, 10);
351                         },
352                 y: function (d) { return xPad(d.getFullYear()%100, 0); },
353                 Y: "getFullYear",
354                 z: function (d) {
355                                 var o = d.getTimezoneOffset();
356                                 var H = xPad(parseInt(Math.abs(o/60), 10), 0);
357                                 var M = xPad(Math.abs(o%60), 0);
358                                 return (o>0?"-":"+") + H + M;
359                         },
360                 Z: function (d) {
361                         var tz = d.toString().replace(/^.*:\d\d( GMT[+-]\d+)? \(?([A-Za-z ]+)\)?\d*$/, "$2").replace(/[a-z ]/g, "");
362                         if(tz.length > 4) {
363                                 tz = Dt.formats.z(d);
364                         }
365                         return tz;
366                 },
367                 "%": function (d) { return "%"; }
368         },
369
370         aggregates: {
371                 c: "locale",
372                 D: "%m/%d/%y",
373                 F: "%Y-%m-%d",
374                 h: "%b",
375                 n: "\n",
376                 r: "locale",
377                 R: "%H:%M",
378                 t: "\t",
379                 T: "%H:%M:%S",
380                 x: "locale",
381                 X: "locale"
382                 //"+": "%a %b %e %T %Z %Y"
383         },
384
385          /**
386          * Takes a native JavaScript Date and formats it as a string for display to user.
387          *
388          * @for DataType.Date
389          * @method format
390          * @param oDate {Date} Date.
391          * @param oConfig {Object} (Optional) Object literal of configuration values:
392          *  <dl>
393          *   <dt>format {String} (Optional)</dt>
394          *   <dd>
395          *   <p>
396          *   Any strftime string is supported, such as "%I:%M:%S %p". strftime has several format specifiers defined by the Open group at 
397          *   <a href="http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html">http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html</a>
398          *   PHP added a few of its own, defined at <a href="http://www.php.net/strftime">http://www.php.net/strftime</a>
399          *   </p>
400          *   <p>
401          *   This javascript implementation supports all the PHP specifiers and a few more.  The full list is below.
402          *   </p>
403          *   <p>
404          *   If not specified, it defaults to the ISO8601 standard date format: %Y-%m-%d.  This may be overridden by changing Y.config.dateFormat
405          *   </p>
406          *   <dl>
407          *      <dt>%a</dt> <dd>abbreviated weekday name according to the current locale</dd>
408          *      <dt>%A</dt> <dd>full weekday name according to the current locale</dd>
409          *      <dt>%b</dt> <dd>abbreviated month name according to the current locale</dd>
410          *      <dt>%B</dt> <dd>full month name according to the current locale</dd>
411          *      <dt>%c</dt> <dd>preferred date and time representation for the current locale</dd>
412          *      <dt>%C</dt> <dd>century number (the year divided by 100 and truncated to an integer, range 00 to 99)</dd>
413          *      <dt>%d</dt> <dd>day of the month as a decimal number (range 01 to 31)</dd>
414          *      <dt>%D</dt> <dd>same as %m/%d/%y</dd>
415          *      <dt>%e</dt> <dd>day of the month as a decimal number, a single digit is preceded by a space (range " 1" to "31")</dd>
416          *      <dt>%F</dt> <dd>same as %Y-%m-%d (ISO 8601 date format)</dd>
417          *      <dt>%g</dt> <dd>like %G, but without the century</dd>
418          *      <dt>%G</dt> <dd>The 4-digit year corresponding to the ISO week number</dd>
419          *      <dt>%h</dt> <dd>same as %b</dd>
420          *      <dt>%H</dt> <dd>hour as a decimal number using a 24-hour clock (range 00 to 23)</dd>
421          *      <dt>%I</dt> <dd>hour as a decimal number using a 12-hour clock (range 01 to 12)</dd>
422          *      <dt>%j</dt> <dd>day of the year as a decimal number (range 001 to 366)</dd>
423          *      <dt>%k</dt> <dd>hour as a decimal number using a 24-hour clock (range 0 to 23); single digits are preceded by a blank. (See also %H.)</dd>
424          *      <dt>%l</dt> <dd>hour as a decimal number using a 12-hour clock (range 1 to 12); single digits are preceded by a blank. (See also %I.) </dd>
425          *      <dt>%m</dt> <dd>month as a decimal number (range 01 to 12)</dd>
426          *      <dt>%M</dt> <dd>minute as a decimal number</dd>
427          *      <dt>%n</dt> <dd>newline character</dd>
428          *      <dt>%p</dt> <dd>either "AM" or "PM" according to the given time value, or the corresponding strings for the current locale</dd>
429          *      <dt>%P</dt> <dd>like %p, but lower case</dd>
430          *      <dt>%r</dt> <dd>time in a.m. and p.m. notation equal to %I:%M:%S %p</dd>
431          *      <dt>%R</dt> <dd>time in 24 hour notation equal to %H:%M</dd>
432          *      <dt>%s</dt> <dd>number of seconds since the Epoch, ie, since 1970-01-01 00:00:00 UTC</dd>
433          *      <dt>%S</dt> <dd>second as a decimal number</dd>
434          *      <dt>%t</dt> <dd>tab character</dd>
435          *      <dt>%T</dt> <dd>current time, equal to %H:%M:%S</dd>
436          *      <dt>%u</dt> <dd>weekday as a decimal number [1,7], with 1 representing Monday</dd>
437          *      <dt>%U</dt> <dd>week number of the current year as a decimal number, starting with the
438          *                      first Sunday as the first day of the first week</dd>
439          *      <dt>%V</dt> <dd>The ISO 8601:1988 week number of the current year as a decimal number,
440          *                      range 01 to 53, where week 1 is the first week that has at least 4 days
441          *                      in the current year, and with Monday as the first day of the week.</dd>
442          *      <dt>%w</dt> <dd>day of the week as a decimal, Sunday being 0</dd>
443          *      <dt>%W</dt> <dd>week number of the current year as a decimal number, starting with the
444          *                      first Monday as the first day of the first week</dd>
445          *      <dt>%x</dt> <dd>preferred date representation for the current locale without the time</dd>
446          *      <dt>%X</dt> <dd>preferred time representation for the current locale without the date</dd>
447          *      <dt>%y</dt> <dd>year as a decimal number without a century (range 00 to 99)</dd>
448          *      <dt>%Y</dt> <dd>year as a decimal number including the century</dd>
449          *      <dt>%z</dt> <dd>numerical time zone representation</dd>
450          *      <dt>%Z</dt> <dd>time zone name or abbreviation</dd>
451          *      <dt>%%</dt> <dd>a literal "%" character</dd>
452          *   </dl>
453          *  </dd>
454          *  <dt>locale {String} (Optional)</dt>
455          *  <dd>
456          *   The locale to use when displaying days of week, months of the year, and other locale specific
457          *   strings. If not specified, this defaults to "en" (though this may be overridden by changing Y.config.locale).
458          *   The following locales are built in:
459          *   <dl>
460          *    <dt>en</dt>
461          *    <dd>English</dd>
462          *    <dt>en-US</dt>
463          *    <dd>US English</dd>
464          *    <dt>en-GB</dt>
465          *    <dd>British English</dd>
466          *    <dt>en-AU</dt>
467          *    <dd>Australian English (identical to British English)</dd>
468          *   </dl>
469          *   More locales may be added by subclassing of Y.DataType.Date.Locale["en"].
470          *   See Y.DataType.Date.Locale for more information.
471          *  </dd>
472          * </dl>
473          * @return {String} Formatted date for display.
474          */
475         format : function (oDate, oConfig) {
476                 oConfig = oConfig || {};
477                 
478                 if(!Y.Lang.isDate(oDate)) {
479                         return Y.Lang.isValue(oDate) ? oDate : "";
480                 }
481
482                 var format = oConfig.format || Y.config.dateFormat,
483                         sLocale = oConfig.locale || Y.config.locale,
484                         LOCALE = Y.DataType.Date.Locale;
485
486                 sLocale = sLocale.replace(/_/g, "-");
487                 
488                 // Make sure we have a definition for the requested locale, or default to en.
489                 if(!LOCALE[sLocale]) {
490                         var tmpLocale = sLocale.replace(/-[a-zA-Z]+$/, "");
491                         if(tmpLocale in LOCALE) {
492                                 sLocale = tmpLocale;
493                         } else if(Y.config.locale in LOCALE) {
494                                 sLocale = Y.config.locale;
495                         } else {
496                                 sLocale = "en";
497                         }
498                 }
499
500                 var aLocale = LOCALE[sLocale];
501
502                 var replace_aggs = function (m0, m1) {
503                         var f = Dt.aggregates[m1];
504                         return (f === "locale" ? aLocale[m1] : f);
505                 };
506
507                 var replace_formats = function (m0, m1) {
508                         var f = Dt.formats[m1];
509                         switch(Y.Lang.type(f)) {
510                                 case "string":                                  // string => built in date function
511                                         return oDate[f]();
512                                 case "function":                                // function => our own function
513                                         return f.call(oDate, oDate, aLocale);
514                                 case "array":                                   // built in function with padding
515                                         if(Y.Lang.type(f[0]) === "string") {
516                                                 return xPad(oDate[f[0]](), f[1]);
517                                         } // no break; (fall through to default:)
518                                 default:
519                                         return m1;
520                         }
521                 };
522
523                 // First replace aggregates (run in a loop because an agg may be made up of other aggs)
524                 while(format.match(/%[cDFhnrRtTxX]/)) {
525                         format = format.replace(/%([cDFhnrRtTxX])/g, replace_aggs);
526                 }
527
528                 // Now replace formats (do not run in a loop otherwise %%a will be replace with the value of %a)
529                 var str = format.replace(/%([aAbBCdegGHIjklmMpPsSuUVwWyYzZ%])/g, replace_formats);
530
531                 replace_aggs = replace_formats = undefined;
532
533                 return str;
534         }
535 };
536
537 Y.mix(Y.namespace("DataType.Date"), Dt);
538
539 /**
540  * @module datatype
541 */
542
543 /**
544  * The Date.Locale class is a container for all localised date strings
545  * used by Y.DataType.Date. It is used internally, but may be extended
546  * to provide new date localisations.
547  *
548  * To create your own Locale, follow these steps:
549  * <ol>
550  *  <li>Find an existing locale that matches closely with your needs</li>
551  *  <li>Use this as your base class.  Use Y.DataType.Date.Locale["en"] if nothing
552  *   matches.</li>
553  *  <li>Create your own class as an extension of the base class using
554  *   Y.merge, and add your own localisations where needed.</li>
555  * </ol>
556  * See the Y.DataType.Date.Locale["en-US"] and Y.DataType.Date.Locale["en-GB"]
557  * classes which extend Y.DataType.Date.Locale["en"].
558  *
559  * For example, to implement locales for French french and Canadian french,
560  * we would do the following:
561  * <ol>
562  *  <li>For French french, we have no existing similar locale, so use
563  *   Y.DataType.Date.Locale["en"] as the base, and extend it:
564  *   <pre>
565  *      Y.DataType.Date.Locale["fr"] = Y.merge(Y.DataType.Date.Locale, {
566  *          a: ["dim", "lun", "mar", "mer", "jeu", "ven", "sam"],
567  *          A: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"],
568  *          b: ["jan", "f&eacute;v", "mar", "avr", "mai", "jun", "jui", "ao&ucirc;", "sep", "oct", "nov", "d&eacute;c"],
569  *          B: ["janvier", "f&eacute;vrier", "mars", "avril", "mai", "juin", "juillet", "ao&ucirc;t", "septembre", "octobre", "novembre", "d&eacute;cembre"],
570  *          c: "%a %d %b %Y %T %Z",
571  *          p: ["", ""],
572  *          P: ["", ""],
573  *          x: "%d.%m.%Y",
574  *          X: "%T"
575  *      });
576  *   </pre>
577  *  </li>
578  *  <li>For Canadian french, we start with French french and change the meaning of \%x:
579  *   <pre>
580  *      Y.DataType.Date.Locale["fr-CA"] = Y.merge(Y.DataType.Date.Locale["fr"], {
581  *          x: "%Y-%m-%d"
582  *      });
583  *   </pre>
584  *  </li>
585  * </ol>
586  *
587  * With that, you can use your new locales:
588  * <pre>
589  *    var d = new Date("2008/04/22");
590  *    Y.DataType.Date.format(d, { format: "%A, %d %B == %x", locale: "fr" });
591  * </pre>
592  * will return:
593  * <pre>
594  *    mardi, 22 avril == 22.04.2008
595  * </pre>
596  * And
597  * <pre>
598  *    Y.DataType.Date.format(d, {format: "%A, %d %B == %x", locale: "fr-CA" });
599  * </pre>
600  * Will return:
601  * <pre>
602  *   mardi, 22 avril == 2008-04-22
603  * </pre>
604  * @requires oop
605  * @class DataType.Date.Locale
606  * @static
607  */
608 var YDateEn = {
609         a: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
610         A: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
611         b: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
612         B: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
613         c: "%a %d %b %Y %T %Z",
614         p: ["AM", "PM"],
615         P: ["am", "pm"],
616         r: "%I:%M:%S %p",
617         x: "%d/%m/%y",
618         X: "%T"
619 };
620
621 Y.namespace("DataType.Date.Locale");
622
623 Y.DataType.Date.Locale["en"] = YDateEn;
624
625 Y.DataType.Date.Locale["en-US"] = Y.merge(YDateEn, {
626         c: "%a %d %b %Y %I:%M:%S %p %Z",
627         x: "%m/%d/%Y",
628         X: "%I:%M:%S %p"
629 });
630
631 Y.DataType.Date.Locale["en-GB"] = Y.merge(YDateEn, {
632         r: "%l:%M:%S %P %Z"
633 });
634 Y.DataType.Date.Locale["en-AU"] = Y.merge(YDateEn);
635
636
637
638
639
640 }, '3.0.0' );
641
642
643
644 YUI.add('datatype-date', function(Y){}, '3.0.0' ,{use:['datatype-date-parse', 'datatype-date-format']});
645
646
647 YUI.add('datatype-xml-parse', function(Y) {
648
649 /**
650  * Parse XML submodule.
651  *
652  * @module datatype
653  * @submodule datatype-xml-parse
654  * @for DataType.XML
655  */
656
657 var LANG = Y.Lang;
658
659 Y.mix(Y.namespace("DataType.XML"), {
660     /**
661      * Converts data to type XMLDocument.
662      *
663      * @method parse
664      * @param data {String} Data to convert.
665      * @return {XMLDoc} XML Document.
666      */
667     parse: function(data) {
668         var xmlDoc = null;
669         if(LANG.isString(data)) {
670             try {
671                 if(!LANG.isUndefined(DOMParser)) {
672                     xmlDoc = new DOMParser().parseFromString(data, "text/xml");
673                 }
674             }
675             catch(e) {
676                 try {
677                     if(!LANG.isUndefined(ActiveXObject)) {
678                             xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
679                             xmlDoc.async = false;
680                             xmlDoc.loadXML(data);
681                     }
682                 }
683                 catch(ee) {
684                 }
685             }
686         }
687         
688         if( (LANG.isNull(xmlDoc)) || (LANG.isNull(xmlDoc.documentElement)) || (xmlDoc.documentElement.nodeName === "parsererror") ) {
689         }
690         
691         return xmlDoc;
692     }
693 });
694
695 // Add Parsers shortcut
696 Y.namespace("Parsers").xml = Y.DataType.XML.parse;
697
698
699
700
701 }, '3.0.0' );
702
703 YUI.add('datatype-xml-format', function(Y) {
704
705 /**
706  * Format XML submodule.
707  *
708  * @module datatype
709  * @submodule datatype-xml-format
710  */
711
712 /**
713  * XML submodule.
714  *
715  * @module datatype
716  * @submodule datatype-xml
717  */
718
719 /**
720  * DataType.XML provides a set of utility functions to operate against XML documents.
721  *
722  * @class DataType.XML
723  * @static
724  */
725 var LANG = Y.Lang;
726
727 Y.mix(Y.namespace("DataType.XML"), {
728     /**
729      * Converts data to type XMLDocument.
730      *
731      * @method format
732      * @param data {XMLDoc} Data to convert.
733      * @return {String} String.
734      */
735     format: function(data) {
736         try {
737             if(!LANG.isUndefined(XMLSerializer)) {
738                 return (new XMLSerializer()).serializeToString(data);
739             }
740         }
741         catch(e) {
742             if(data && data.xml) {
743                 return data.xml;
744             }
745             else {
746                 return (LANG.isValue(data) && data.toString) ? data.toString() : "";
747             }
748         }
749     }
750 });
751
752
753
754
755 }, '3.0.0' );
756
757
758
759 YUI.add('datatype-xml', function(Y){}, '3.0.0' ,{use:['datatype-xml-parse', 'datatype-xml-format']});
760
761
762
763
764 YUI.add('datatype', function(Y){}, '3.0.0' ,{use:['datatype-number', 'datatype-date', 'datatype-xml']});
765