You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1362 lines
62 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Date'>/**
  19. </span> * @class Date
  20. *
  21. * The date parsing and formatting syntax contains a subset of
  22. * &lt;a href=&quot;http://www.php.net/date&quot;&gt;PHP's date() function&lt;/a&gt;, and the formats that are
  23. * supported will provide results equivalent to their PHP versions.
  24. *
  25. * The following is a list of all currently supported formats:
  26. * &lt;pre&gt;
  27. Format Description Example returned values
  28. ------ ----------------------------------------------------------------------- -----------------------
  29. d Day of the month, 2 digits with leading zeros 01 to 31
  30. D A short textual representation of the day of the week Mon to Sun
  31. j Day of the month without leading zeros 1 to 31
  32. l A full textual representation of the day of the week Sunday to Saturday
  33. N ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday)
  34. S English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j
  35. w Numeric representation of the day of the week 0 (for Sunday) to 6 (for Saturday)
  36. z The day of the year (starting from 0) 0 to 364 (365 in leap years)
  37. W ISO-8601 week number of year, weeks starting on Monday 01 to 53
  38. F A full textual representation of a month, such as January or March January to December
  39. m Numeric representation of a month, with leading zeros 01 to 12
  40. M A short textual representation of a month Jan to Dec
  41. n Numeric representation of a month, without leading zeros 1 to 12
  42. t Number of days in the given month 28 to 31
  43. L Whether it's a leap year 1 if it is a leap year, 0 otherwise.
  44. o ISO-8601 year number (identical to (Y), but if the ISO week number (W) Examples: 1998 or 2004
  45. belongs to the previous or next year, that year is used instead)
  46. Y A full numeric representation of a year, 4 digits Examples: 1999 or 2003
  47. y A two digit representation of a year Examples: 99 or 03
  48. a Lowercase Ante meridiem and Post meridiem am or pm
  49. A Uppercase Ante meridiem and Post meridiem AM or PM
  50. g 12-hour format of an hour without leading zeros 1 to 12
  51. G 24-hour format of an hour without leading zeros 0 to 23
  52. h 12-hour format of an hour with leading zeros 01 to 12
  53. H 24-hour format of an hour with leading zeros 00 to 23
  54. i Minutes, with leading zeros 00 to 59
  55. s Seconds, with leading zeros 00 to 59
  56. u Decimal fraction of a second Examples:
  57. (minimum 1 digit, arbitrary number of digits allowed) 001 (i.e. 0.001s) or
  58. 100 (i.e. 0.100s) or
  59. 999 (i.e. 0.999s) or
  60. 999876543210 (i.e. 0.999876543210s)
  61. O Difference to Greenwich time (GMT) in hours and minutes Example: +1030
  62. P Difference to Greenwich time (GMT) with colon between hours and minutes Example: -08:00
  63. T Timezone abbreviation of the machine running the code Examples: EST, MDT, PDT ...
  64. Z Timezone offset in seconds (negative if west of UTC, positive if east) -43200 to 50400
  65. c ISO 8601 date
  66. Notes: Examples:
  67. 1) If unspecified, the month / day defaults to the current month / day, 1991 or
  68. the time defaults to midnight, while the timezone defaults to the 1992-10 or
  69. browser's timezone. If a time is specified, it must include both hours 1993-09-20 or
  70. and minutes. The &quot;T&quot; delimiter, seconds, milliseconds and timezone 1994-08-19T16:20+01:00 or
  71. are optional. 1995-07-18T17:21:28-02:00 or
  72. 2) The decimal fraction of a second, if specified, must contain at 1996-06-17T18:22:29.98765+03:00 or
  73. least 1 digit (there is no limit to the maximum number 1997-05-16T19:23:30,12345-0400 or
  74. of digits allowed), and may be delimited by either a '.' or a ',' 1998-04-15T20:24:31.2468Z or
  75. Refer to the examples on the right for the various levels of 1999-03-14T20:24:32Z or
  76. date-time granularity which are supported, or see 2000-02-13T21:25:33
  77. http://www.w3.org/TR/NOTE-datetime for more info. 2001-01-12 22:26:34
  78. U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) 1193432466 or -2138434463
  79. M$ Microsoft AJAX serialized dates \/Date(1238606590509)\/ (i.e. UTC milliseconds since epoch) or
  80. \/Date(1238606590509+0800)\/
  81. &lt;/pre&gt;
  82. *
  83. * Example usage (note that you must escape format specifiers with '\\' to render them as character literals):
  84. * &lt;pre&gt;&lt;code&gt;
  85. // Sample date:
  86. // 'Wed Jan 10 2007 15:05:01 GMT-0600 (Central Standard Time)'
  87. var dt = new Date('1/10/2007 03:05:01 PM GMT-0600');
  88. document.write(dt.format('Y-m-d')); // 2007-01-10
  89. document.write(dt.format('F j, Y, g:i a')); // January 10, 2007, 3:05 pm
  90. document.write(dt.format('l, \\t\\he jS \\of F Y h:i:s A')); // Wednesday, the 10th of January 2007 03:05:01 PM
  91. &lt;/code&gt;&lt;/pre&gt;
  92. *
  93. * Here are some standard date/time patterns that you might find helpful. They
  94. * are not part of the source of Date.js, but to use them you can simply copy this
  95. * block of code into any script that is included after Date.js and they will also become
  96. * globally available on the Date object. Feel free to add or remove patterns as needed in your code.
  97. * &lt;pre&gt;&lt;code&gt;
  98. Date.patterns = {
  99. ISO8601Long:&quot;Y-m-d H:i:s&quot;,
  100. ISO8601Short:&quot;Y-m-d&quot;,
  101. ShortDate: &quot;n/j/Y&quot;,
  102. LongDate: &quot;l, F d, Y&quot;,
  103. FullDateTime: &quot;l, F d, Y g:i:s A&quot;,
  104. MonthDay: &quot;F d&quot;,
  105. ShortTime: &quot;g:i A&quot;,
  106. LongTime: &quot;g:i:s A&quot;,
  107. SortableDateTime: &quot;Y-m-d\\TH:i:s&quot;,
  108. UniversalSortableDateTime: &quot;Y-m-d H:i:sO&quot;,
  109. YearMonth: &quot;F, Y&quot;
  110. };
  111. &lt;/code&gt;&lt;/pre&gt;
  112. *
  113. * Example usage:
  114. * &lt;pre&gt;&lt;code&gt;
  115. var dt = new Date();
  116. document.write(dt.format(Date.patterns.ShortDate));
  117. &lt;/code&gt;&lt;/pre&gt;
  118. * &lt;p&gt;Developer-written, custom formats may be used by supplying both a formatting and a parsing function
  119. * which perform to specialized requirements. The functions are stored in {@link #parseFunctions} and {@link #formatFunctions}.&lt;/p&gt;
  120. */
  121. /*
  122. * Most of the date-formatting functions below are the excellent work of Baron Schwartz.
  123. * (see http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/)
  124. * They generate precompiled functions from format patterns instead of parsing and
  125. * processing each pattern every time a date is formatted. These functions are available
  126. * on every Date object.
  127. */
  128. (function() {
  129. <span id='Date-static-property-useStrict'>/**
  130. </span> * Global flag which determines if strict date parsing should be used.
  131. * Strict date parsing will not roll-over invalid dates, which is the
  132. * default behaviour of javascript Date objects.
  133. * (see {@link #parseDate} for more information)
  134. * Defaults to &lt;tt&gt;false&lt;/tt&gt;.
  135. * @static
  136. * @type Boolean
  137. */
  138. Date.useStrict = false;
  139. // create private copy of Ext's String.format() method
  140. // - to remove unnecessary dependency
  141. // - to resolve namespace conflict with M$-Ajax's implementation
  142. function xf(format) {
  143. var args = Array.prototype.slice.call(arguments, 1);
  144. return format.replace(/\{(\d+)\}/g, function(m, i) {
  145. return args[i];
  146. });
  147. }
  148. // private
  149. Date.formatCodeToRegex = function(character, currentGroup) {
  150. // Note: currentGroup - position in regex result array (see notes for Date.parseCodes below)
  151. var p = Date.parseCodes[character];
  152. if (p) {
  153. p = typeof p == 'function'? p() : p;
  154. Date.parseCodes[character] = p; // reassign function result to prevent repeated execution
  155. }
  156. return p ? Ext.applyIf({
  157. c: p.c ? xf(p.c, currentGroup || &quot;{0}&quot;) : p.c
  158. }, p) : {
  159. g:0,
  160. c:null,
  161. s:Ext.escapeRe(character) // treat unrecognised characters as literals
  162. };
  163. };
  164. // private shorthand for Date.formatCodeToRegex since we'll be using it fairly often
  165. var $f = Date.formatCodeToRegex;
  166. Ext.apply(Date, {
  167. <span id='Date-static-property-parseFunctions'> /**
  168. </span> * &lt;p&gt;An object hash in which each property is a date parsing function. The property name is the
  169. * format string which that function parses.&lt;/p&gt;
  170. * &lt;p&gt;This object is automatically populated with date parsing functions as
  171. * date formats are requested for Ext standard formatting strings.&lt;/p&gt;
  172. * &lt;p&gt;Custom parsing functions may be inserted into this object, keyed by a name which from then on
  173. * may be used as a format string to {@link #parseDate}.&lt;p&gt;
  174. * &lt;p&gt;Example:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
  175. Date.parseFunctions['x-date-format'] = myDateParser;
  176. &lt;/code&gt;&lt;/pre&gt;
  177. * &lt;p&gt;A parsing function should return a Date object, and is passed the following parameters:&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  178. * &lt;li&gt;&lt;code&gt;date&lt;/code&gt; : String&lt;div class=&quot;sub-desc&quot;&gt;The date string to parse.&lt;/div&gt;&lt;/li&gt;
  179. * &lt;li&gt;&lt;code&gt;strict&lt;/code&gt; : Boolean&lt;div class=&quot;sub-desc&quot;&gt;True to validate date strings while parsing
  180. * (i.e. prevent javascript Date &quot;rollover&quot;) (The default must be false).
  181. * Invalid date strings should return null when parsed.&lt;/div&gt;&lt;/li&gt;
  182. * &lt;/ul&gt;&lt;/div&gt;&lt;/p&gt;
  183. * &lt;p&gt;To enable Dates to also be &lt;i&gt;formatted&lt;/i&gt; according to that format, a corresponding
  184. * formatting function must be placed into the {@link #formatFunctions} property.
  185. * @property parseFunctions
  186. * @static
  187. * @type Object
  188. */
  189. parseFunctions: {
  190. &quot;M$&quot;: function(input, strict) {
  191. // note: the timezone offset is ignored since the M$ Ajax server sends
  192. // a UTC milliseconds-since-Unix-epoch value (negative values are allowed)
  193. var re = new RegExp('\\/Date\\(([-+])?(\\d+)(?:[+-]\\d{4})?\\)\\/');
  194. var r = (input || '').match(re);
  195. return r? new Date(((r[1] || '') + r[2]) * 1) : null;
  196. }
  197. },
  198. parseRegexes: [],
  199. <span id='Date-static-property-formatFunctions'> /**
  200. </span> * &lt;p&gt;An object hash in which each property is a date formatting function. The property name is the
  201. * format string which corresponds to the produced formatted date string.&lt;/p&gt;
  202. * &lt;p&gt;This object is automatically populated with date formatting functions as
  203. * date formats are requested for Ext standard formatting strings.&lt;/p&gt;
  204. * &lt;p&gt;Custom formatting functions may be inserted into this object, keyed by a name which from then on
  205. * may be used as a format string to {@link #format}. Example:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
  206. Date.formatFunctions['x-date-format'] = myDateFormatter;
  207. &lt;/code&gt;&lt;/pre&gt;
  208. * &lt;p&gt;A formatting function should return a string representation of the passed Date object, and is passed the following parameters:&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  209. * &lt;li&gt;&lt;code&gt;date&lt;/code&gt; : Date&lt;div class=&quot;sub-desc&quot;&gt;The Date to format.&lt;/div&gt;&lt;/li&gt;
  210. * &lt;/ul&gt;&lt;/div&gt;&lt;/p&gt;
  211. * &lt;p&gt;To enable date strings to also be &lt;i&gt;parsed&lt;/i&gt; according to that format, a corresponding
  212. * parsing function must be placed into the {@link #parseFunctions} property.
  213. * @property formatFunctions
  214. * @static
  215. * @type Object
  216. */
  217. formatFunctions: {
  218. &quot;M$&quot;: function() {
  219. // UTC milliseconds since Unix epoch (M$-AJAX serialized date format (MRSF))
  220. return '\\/Date(' + this.getTime() + ')\\/';
  221. }
  222. },
  223. y2kYear : 50,
  224. <span id='Date-static-property-MILLI'> /**
  225. </span> * Date interval constant
  226. * @static
  227. * @type String
  228. */
  229. MILLI : &quot;ms&quot;,
  230. <span id='Date-static-property-SECOND'> /**
  231. </span> * Date interval constant
  232. * @static
  233. * @type String
  234. */
  235. SECOND : &quot;s&quot;,
  236. <span id='Date-static-property-MINUTE'> /**
  237. </span> * Date interval constant
  238. * @static
  239. * @type String
  240. */
  241. MINUTE : &quot;mi&quot;,
  242. <span id='Date-static-property-HOUR'> /** Date interval constant
  243. </span> * @static
  244. * @type String
  245. */
  246. HOUR : &quot;h&quot;,
  247. <span id='Date-static-property-DAY'> /**
  248. </span> * Date interval constant
  249. * @static
  250. * @type String
  251. */
  252. DAY : &quot;d&quot;,
  253. <span id='Date-static-property-MONTH'> /**
  254. </span> * Date interval constant
  255. * @static
  256. * @type String
  257. */
  258. MONTH : &quot;mo&quot;,
  259. <span id='Date-static-property-YEAR'> /**
  260. </span> * Date interval constant
  261. * @static
  262. * @type String
  263. */
  264. YEAR : &quot;y&quot;,
  265. <span id='Date-static-property-defaults'> /**
  266. </span> * &lt;p&gt;An object hash containing default date values used during date parsing.&lt;/p&gt;
  267. * &lt;p&gt;The following properties are available:&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  268. * &lt;li&gt;&lt;code&gt;y&lt;/code&gt; : Number&lt;div class=&quot;sub-desc&quot;&gt;The default year value. (defaults to undefined)&lt;/div&gt;&lt;/li&gt;
  269. * &lt;li&gt;&lt;code&gt;m&lt;/code&gt; : Number&lt;div class=&quot;sub-desc&quot;&gt;The default 1-based month value. (defaults to undefined)&lt;/div&gt;&lt;/li&gt;
  270. * &lt;li&gt;&lt;code&gt;d&lt;/code&gt; : Number&lt;div class=&quot;sub-desc&quot;&gt;The default day value. (defaults to undefined)&lt;/div&gt;&lt;/li&gt;
  271. * &lt;li&gt;&lt;code&gt;h&lt;/code&gt; : Number&lt;div class=&quot;sub-desc&quot;&gt;The default hour value. (defaults to undefined)&lt;/div&gt;&lt;/li&gt;
  272. * &lt;li&gt;&lt;code&gt;i&lt;/code&gt; : Number&lt;div class=&quot;sub-desc&quot;&gt;The default minute value. (defaults to undefined)&lt;/div&gt;&lt;/li&gt;
  273. * &lt;li&gt;&lt;code&gt;s&lt;/code&gt; : Number&lt;div class=&quot;sub-desc&quot;&gt;The default second value. (defaults to undefined)&lt;/div&gt;&lt;/li&gt;
  274. * &lt;li&gt;&lt;code&gt;ms&lt;/code&gt; : Number&lt;div class=&quot;sub-desc&quot;&gt;The default millisecond value. (defaults to undefined)&lt;/div&gt;&lt;/li&gt;
  275. * &lt;/ul&gt;&lt;/div&gt;&lt;/p&gt;
  276. * &lt;p&gt;Override these properties to customize the default date values used by the {@link #parseDate} method.&lt;/p&gt;
  277. * &lt;p&gt;&lt;b&gt;Note: In countries which experience Daylight Saving Time (i.e. DST), the &lt;tt&gt;h&lt;/tt&gt;, &lt;tt&gt;i&lt;/tt&gt;, &lt;tt&gt;s&lt;/tt&gt;
  278. * and &lt;tt&gt;ms&lt;/tt&gt; properties may coincide with the exact time in which DST takes effect.
  279. * It is the responsiblity of the developer to account for this.&lt;/b&gt;&lt;/p&gt;
  280. * Example Usage:
  281. * &lt;pre&gt;&lt;code&gt;
  282. // set default day value to the first day of the month
  283. Date.defaults.d = 1;
  284. // parse a February date string containing only year and month values.
  285. // setting the default day value to 1 prevents weird date rollover issues
  286. // when attempting to parse the following date string on, for example, March 31st 2009.
  287. Date.parseDate('2009-02', 'Y-m'); // returns a Date object representing February 1st 2009
  288. &lt;/code&gt;&lt;/pre&gt;
  289. * @property defaults
  290. * @static
  291. * @type Object
  292. */
  293. defaults: {},
  294. <span id='Date-static-property-dayNames'> /**
  295. </span> * An array of textual day names.
  296. * Override these values for international dates.
  297. * Example:
  298. * &lt;pre&gt;&lt;code&gt;
  299. Date.dayNames = [
  300. 'SundayInYourLang',
  301. 'MondayInYourLang',
  302. ...
  303. ];
  304. &lt;/code&gt;&lt;/pre&gt;
  305. * @type Array
  306. * @static
  307. */
  308. dayNames : [
  309. &quot;Sunday&quot;,
  310. &quot;Monday&quot;,
  311. &quot;Tuesday&quot;,
  312. &quot;Wednesday&quot;,
  313. &quot;Thursday&quot;,
  314. &quot;Friday&quot;,
  315. &quot;Saturday&quot;
  316. ],
  317. <span id='Date-static-property-monthNames'> /**
  318. </span> * An array of textual month names.
  319. * Override these values for international dates.
  320. * Example:
  321. * &lt;pre&gt;&lt;code&gt;
  322. Date.monthNames = [
  323. 'JanInYourLang',
  324. 'FebInYourLang',
  325. ...
  326. ];
  327. &lt;/code&gt;&lt;/pre&gt;
  328. * @type Array
  329. * @static
  330. */
  331. monthNames : [
  332. &quot;January&quot;,
  333. &quot;February&quot;,
  334. &quot;March&quot;,
  335. &quot;April&quot;,
  336. &quot;May&quot;,
  337. &quot;June&quot;,
  338. &quot;July&quot;,
  339. &quot;August&quot;,
  340. &quot;September&quot;,
  341. &quot;October&quot;,
  342. &quot;November&quot;,
  343. &quot;December&quot;
  344. ],
  345. <span id='Date-static-property-monthNumbers'> /**
  346. </span> * An object hash of zero-based javascript month numbers (with short month names as keys. note: keys are case-sensitive).
  347. * Override these values for international dates.
  348. * Example:
  349. * &lt;pre&gt;&lt;code&gt;
  350. Date.monthNumbers = {
  351. 'ShortJanNameInYourLang':0,
  352. 'ShortFebNameInYourLang':1,
  353. ...
  354. };
  355. &lt;/code&gt;&lt;/pre&gt;
  356. * @type Object
  357. * @static
  358. */
  359. monthNumbers : {
  360. Jan:0,
  361. Feb:1,
  362. Mar:2,
  363. Apr:3,
  364. May:4,
  365. Jun:5,
  366. Jul:6,
  367. Aug:7,
  368. Sep:8,
  369. Oct:9,
  370. Nov:10,
  371. Dec:11
  372. },
  373. <span id='Date-static-method-getShortMonthName'> /**
  374. </span> * Get the short month name for the given month number.
  375. * Override this function for international dates.
  376. * @param {Number} month A zero-based javascript month number.
  377. * @return {String} The short month name.
  378. * @static
  379. */
  380. getShortMonthName : function(month) {
  381. return Date.monthNames[month].substring(0, 3);
  382. },
  383. <span id='Date-static-method-getShortDayName'> /**
  384. </span> * Get the short day name for the given day number.
  385. * Override this function for international dates.
  386. * @param {Number} day A zero-based javascript day number.
  387. * @return {String} The short day name.
  388. * @static
  389. */
  390. getShortDayName : function(day) {
  391. return Date.dayNames[day].substring(0, 3);
  392. },
  393. <span id='Date-static-method-getMonthNumber'> /**
  394. </span> * Get the zero-based javascript month number for the given short/full month name.
  395. * Override this function for international dates.
  396. * @param {String} name The short/full month name.
  397. * @return {Number} The zero-based javascript month number.
  398. * @static
  399. */
  400. getMonthNumber : function(name) {
  401. // handle camel casing for english month names (since the keys for the Date.monthNumbers hash are case sensitive)
  402. return Date.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
  403. },
  404. <span id='Date-static-method-formatContainsHourInfo'> /**
  405. </span> * Checks if the specified format contains hour information
  406. * @param {Object} format The format to check
  407. * @return {Boolean} True if the format contains hour information
  408. * @static
  409. */
  410. formatContainsHourInfo : (function(){
  411. var stripEscapeRe = /(\\.)/g,
  412. hourInfoRe = /([gGhHisucUOPZ]|M\$)/;
  413. return function(format){
  414. return hourInfoRe.test(format.replace(stripEscapeRe, ''));
  415. };
  416. })(),
  417. <span id='Date-static-property-formatCodes'> /**
  418. </span> * The base format-code to formatting-function hashmap used by the {@link #format} method.
  419. * Formatting functions are strings (or functions which return strings) which
  420. * will return the appropriate value when evaluated in the context of the Date object
  421. * from which the {@link #format} method is called.
  422. * Add to / override these mappings for custom date formatting.
  423. * Note: Date.format() treats characters as literals if an appropriate mapping cannot be found.
  424. * Example:
  425. * &lt;pre&gt;&lt;code&gt;
  426. Date.formatCodes.x = &quot;String.leftPad(this.getDate(), 2, '0')&quot;;
  427. (new Date()).format(&quot;X&quot;); // returns the current day of the month
  428. &lt;/code&gt;&lt;/pre&gt;
  429. * @type Object
  430. * @static
  431. */
  432. formatCodes : {
  433. d: &quot;String.leftPad(this.getDate(), 2, '0')&quot;,
  434. D: &quot;Date.getShortDayName(this.getDay())&quot;, // get localised short day name
  435. j: &quot;this.getDate()&quot;,
  436. l: &quot;Date.dayNames[this.getDay()]&quot;,
  437. N: &quot;(this.getDay() ? this.getDay() : 7)&quot;,
  438. S: &quot;this.getSuffix()&quot;,
  439. w: &quot;this.getDay()&quot;,
  440. z: &quot;this.getDayOfYear()&quot;,
  441. W: &quot;String.leftPad(this.getWeekOfYear(), 2, '0')&quot;,
  442. F: &quot;Date.monthNames[this.getMonth()]&quot;,
  443. m: &quot;String.leftPad(this.getMonth() + 1, 2, '0')&quot;,
  444. M: &quot;Date.getShortMonthName(this.getMonth())&quot;, // get localised short month name
  445. n: &quot;(this.getMonth() + 1)&quot;,
  446. t: &quot;this.getDaysInMonth()&quot;,
  447. L: &quot;(this.isLeapYear() ? 1 : 0)&quot;,
  448. o: &quot;(this.getFullYear() + (this.getWeekOfYear() == 1 &amp;&amp; this.getMonth() &gt; 0 ? +1 : (this.getWeekOfYear() &gt;= 52 &amp;&amp; this.getMonth() &lt; 11 ? -1 : 0)))&quot;,
  449. Y: &quot;String.leftPad(this.getFullYear(), 4, '0')&quot;,
  450. y: &quot;('' + this.getFullYear()).substring(2, 4)&quot;,
  451. a: &quot;(this.getHours() &lt; 12 ? 'am' : 'pm')&quot;,
  452. A: &quot;(this.getHours() &lt; 12 ? 'AM' : 'PM')&quot;,
  453. g: &quot;((this.getHours() % 12) ? this.getHours() % 12 : 12)&quot;,
  454. G: &quot;this.getHours()&quot;,
  455. h: &quot;String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0')&quot;,
  456. H: &quot;String.leftPad(this.getHours(), 2, '0')&quot;,
  457. i: &quot;String.leftPad(this.getMinutes(), 2, '0')&quot;,
  458. s: &quot;String.leftPad(this.getSeconds(), 2, '0')&quot;,
  459. u: &quot;String.leftPad(this.getMilliseconds(), 3, '0')&quot;,
  460. O: &quot;this.getGMTOffset()&quot;,
  461. P: &quot;this.getGMTOffset(true)&quot;,
  462. T: &quot;this.getTimezone()&quot;,
  463. Z: &quot;(this.getTimezoneOffset() * -60)&quot;,
  464. c: function() { // ISO-8601 -- GMT format
  465. for (var c = &quot;Y-m-dTH:i:sP&quot;, code = [], i = 0, l = c.length; i &lt; l; ++i) {
  466. var e = c.charAt(i);
  467. code.push(e == &quot;T&quot; ? &quot;'T'&quot; : Date.getFormatCode(e)); // treat T as a character literal
  468. }
  469. return code.join(&quot; + &quot;);
  470. },
  471. /*
  472. c: function() { // ISO-8601 -- UTC format
  473. return [
  474. &quot;this.getUTCFullYear()&quot;, &quot;'-'&quot;,
  475. &quot;String.leftPad(this.getUTCMonth() + 1, 2, '0')&quot;, &quot;'-'&quot;,
  476. &quot;String.leftPad(this.getUTCDate(), 2, '0')&quot;,
  477. &quot;'T'&quot;,
  478. &quot;String.leftPad(this.getUTCHours(), 2, '0')&quot;, &quot;':'&quot;,
  479. &quot;String.leftPad(this.getUTCMinutes(), 2, '0')&quot;, &quot;':'&quot;,
  480. &quot;String.leftPad(this.getUTCSeconds(), 2, '0')&quot;,
  481. &quot;'Z'&quot;
  482. ].join(&quot; + &quot;);
  483. },
  484. */
  485. U: &quot;Math.round(this.getTime() / 1000)&quot;
  486. },
  487. <span id='Date-static-method-isValid'> /**
  488. </span> * Checks if the passed Date parameters will cause a javascript Date &quot;rollover&quot;.
  489. * @param {Number} year 4-digit year
  490. * @param {Number} month 1-based month-of-year
  491. * @param {Number} day Day of month
  492. * @param {Number} hour (optional) Hour
  493. * @param {Number} minute (optional) Minute
  494. * @param {Number} second (optional) Second
  495. * @param {Number} millisecond (optional) Millisecond
  496. * @return {Boolean} true if the passed parameters do not cause a Date &quot;rollover&quot;, false otherwise.
  497. * @static
  498. */
  499. isValid : function(y, m, d, h, i, s, ms) {
  500. // setup defaults
  501. h = h || 0;
  502. i = i || 0;
  503. s = s || 0;
  504. ms = ms || 0;
  505. // Special handling for year &lt; 100
  506. var dt = new Date(y &lt; 100 ? 100 : y, m - 1, d, h, i, s, ms).add(Date.YEAR, y &lt; 100 ? y - 100 : 0);
  507. return y == dt.getFullYear() &amp;&amp;
  508. m == dt.getMonth() + 1 &amp;&amp;
  509. d == dt.getDate() &amp;&amp;
  510. h == dt.getHours() &amp;&amp;
  511. i == dt.getMinutes() &amp;&amp;
  512. s == dt.getSeconds() &amp;&amp;
  513. ms == dt.getMilliseconds();
  514. },
  515. <span id='Date-static-method-parseDate'> /**
  516. </span> * Parses the passed string using the specified date format.
  517. * Note that this function expects normal calendar dates, meaning that months are 1-based (i.e. 1 = January).
  518. * The {@link #defaults} hash will be used for any date value (i.e. year, month, day, hour, minute, second or millisecond)
  519. * which cannot be found in the passed string. If a corresponding default date value has not been specified in the {@link #defaults} hash,
  520. * the current date's year, month, day or DST-adjusted zero-hour time value will be used instead.
  521. * Keep in mind that the input date string must precisely match the specified format string
  522. * in order for the parse operation to be successful (failed parse operations return a null value).
  523. * &lt;p&gt;Example:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
  524. //dt = Fri May 25 2007 (current date)
  525. var dt = new Date();
  526. //dt = Thu May 25 2006 (today&amp;#39;s month/day in 2006)
  527. dt = Date.parseDate(&quot;2006&quot;, &quot;Y&quot;);
  528. //dt = Sun Jan 15 2006 (all date parts specified)
  529. dt = Date.parseDate(&quot;2006-01-15&quot;, &quot;Y-m-d&quot;);
  530. //dt = Sun Jan 15 2006 15:20:01
  531. dt = Date.parseDate(&quot;2006-01-15 3:20:01 PM&quot;, &quot;Y-m-d g:i:s A&quot;);
  532. // attempt to parse Sun Feb 29 2006 03:20:01 in strict mode
  533. dt = Date.parseDate(&quot;2006-02-29 03:20:01&quot;, &quot;Y-m-d H:i:s&quot;, true); // returns null
  534. &lt;/code&gt;&lt;/pre&gt;
  535. * @param {String} input The raw date string.
  536. * @param {String} format The expected date string format.
  537. * @param {Boolean} strict (optional) True to validate date strings while parsing (i.e. prevents javascript Date &quot;rollover&quot;)
  538. (defaults to false). Invalid date strings will return null when parsed.
  539. * @return {Date} The parsed Date.
  540. * @static
  541. */
  542. parseDate : function(input, format, strict) {
  543. var p = Date.parseFunctions;
  544. if (p[format] == null) {
  545. Date.createParser(format);
  546. }
  547. return p[format](input, Ext.isDefined(strict) ? strict : Date.useStrict);
  548. },
  549. // private
  550. getFormatCode : function(character) {
  551. var f = Date.formatCodes[character];
  552. if (f) {
  553. f = typeof f == 'function'? f() : f;
  554. Date.formatCodes[character] = f; // reassign function result to prevent repeated execution
  555. }
  556. // note: unknown characters are treated as literals
  557. return f || (&quot;'&quot; + String.escape(character) + &quot;'&quot;);
  558. },
  559. // private
  560. createFormat : function(format) {
  561. var code = [],
  562. special = false,
  563. ch = '';
  564. for (var i = 0; i &lt; format.length; ++i) {
  565. ch = format.charAt(i);
  566. if (!special &amp;&amp; ch == &quot;\\&quot;) {
  567. special = true;
  568. } else if (special) {
  569. special = false;
  570. code.push(&quot;'&quot; + String.escape(ch) + &quot;'&quot;);
  571. } else {
  572. code.push(Date.getFormatCode(ch));
  573. }
  574. }
  575. Date.formatFunctions[format] = new Function(&quot;return &quot; + code.join('+'));
  576. },
  577. // private
  578. createParser : function() {
  579. var code = [
  580. &quot;var dt, y, m, d, h, i, s, ms, o, z, zz, u, v,&quot;,
  581. &quot;def = Date.defaults,&quot;,
  582. &quot;results = String(input).match(Date.parseRegexes[{0}]);&quot;, // either null, or an array of matched strings
  583. &quot;if(results){&quot;,
  584. &quot;{1}&quot;,
  585. &quot;if(u != null){&quot;, // i.e. unix time is defined
  586. &quot;v = new Date(u * 1000);&quot;, // give top priority to UNIX time
  587. &quot;}else{&quot;,
  588. // create Date object representing midnight of the current day;
  589. // this will provide us with our date defaults
  590. // (note: clearTime() handles Daylight Saving Time automatically)
  591. &quot;dt = (new Date()).clearTime();&quot;,
  592. // date calculations (note: these calculations create a dependency on Ext.num())
  593. &quot;y = Ext.num(y, Ext.num(def.y, dt.getFullYear()));&quot;,
  594. &quot;m = Ext.num(m, Ext.num(def.m - 1, dt.getMonth()));&quot;,
  595. &quot;d = Ext.num(d, Ext.num(def.d, dt.getDate()));&quot;,
  596. // time calculations (note: these calculations create a dependency on Ext.num())
  597. &quot;h = Ext.num(h, Ext.num(def.h, dt.getHours()));&quot;,
  598. &quot;i = Ext.num(i, Ext.num(def.i, dt.getMinutes()));&quot;,
  599. &quot;s = Ext.num(s, Ext.num(def.s, dt.getSeconds()));&quot;,
  600. &quot;ms = Ext.num(ms, Ext.num(def.ms, dt.getMilliseconds()));&quot;,
  601. &quot;if(z &gt;= 0 &amp;&amp; y &gt;= 0){&quot;,
  602. // both the year and zero-based day of year are defined and &gt;= 0.
  603. // these 2 values alone provide sufficient info to create a full date object
  604. // create Date object representing January 1st for the given year
  605. // handle years &lt; 100 appropriately
  606. &quot;v = new Date(y &lt; 100 ? 100 : y, 0, 1, h, i, s, ms).add(Date.YEAR, y &lt; 100 ? y - 100 : 0);&quot;,
  607. // then add day of year, checking for Date &quot;rollover&quot; if necessary
  608. &quot;v = !strict? v : (strict === true &amp;&amp; (z &lt;= 364 || (v.isLeapYear() &amp;&amp; z &lt;= 365))? v.add(Date.DAY, z) : null);&quot;,
  609. &quot;}else if(strict === true &amp;&amp; !Date.isValid(y, m + 1, d, h, i, s, ms)){&quot;, // check for Date &quot;rollover&quot;
  610. &quot;v = null;&quot;, // invalid date, so return null
  611. &quot;}else{&quot;,
  612. // plain old Date object
  613. // handle years &lt; 100 properly
  614. &quot;v = new Date(y &lt; 100 ? 100 : y, m, d, h, i, s, ms).add(Date.YEAR, y &lt; 100 ? y - 100 : 0);&quot;,
  615. &quot;}&quot;,
  616. &quot;}&quot;,
  617. &quot;}&quot;,
  618. &quot;if(v){&quot;,
  619. // favour UTC offset over GMT offset
  620. &quot;if(zz != null){&quot;,
  621. // reset to UTC, then add offset
  622. &quot;v = v.add(Date.SECOND, -v.getTimezoneOffset() * 60 - zz);&quot;,
  623. &quot;}else if(o){&quot;,
  624. // reset to GMT, then add offset
  625. &quot;v = v.add(Date.MINUTE, -v.getTimezoneOffset() + (sn == '+'? -1 : 1) * (hr * 60 + mn));&quot;,
  626. &quot;}&quot;,
  627. &quot;}&quot;,
  628. &quot;return v;&quot;
  629. ].join('\n');
  630. return function(format) {
  631. var regexNum = Date.parseRegexes.length,
  632. currentGroup = 1,
  633. calc = [],
  634. regex = [],
  635. special = false,
  636. ch = &quot;&quot;,
  637. i = 0,
  638. obj,
  639. last;
  640. for (; i &lt; format.length; ++i) {
  641. ch = format.charAt(i);
  642. if (!special &amp;&amp; ch == &quot;\\&quot;) {
  643. special = true;
  644. } else if (special) {
  645. special = false;
  646. regex.push(String.escape(ch));
  647. } else {
  648. obj = $f(ch, currentGroup);
  649. currentGroup += obj.g;
  650. regex.push(obj.s);
  651. if (obj.g &amp;&amp; obj.c) {
  652. if (obj.calcLast) {
  653. last = obj.c;
  654. } else {
  655. calc.push(obj.c);
  656. }
  657. }
  658. }
  659. }
  660. if (last) {
  661. calc.push(last);
  662. }
  663. Date.parseRegexes[regexNum] = new RegExp(&quot;^&quot; + regex.join('') + &quot;$&quot;, 'i');
  664. Date.parseFunctions[format] = new Function(&quot;input&quot;, &quot;strict&quot;, xf(code, regexNum, calc.join('')));
  665. };
  666. }(),
  667. // private
  668. parseCodes : {
  669. /*
  670. * Notes:
  671. * g = {Number} calculation group (0 or 1. only group 1 contributes to date calculations.)
  672. * c = {String} calculation method (required for group 1. null for group 0. {0} = currentGroup - position in regex result array)
  673. * s = {String} regex pattern. all matches are stored in results[], and are accessible by the calculation mapped to 'c'
  674. */
  675. d: {
  676. g:1,
  677. c:&quot;d = parseInt(results[{0}], 10);\n&quot;,
  678. s:&quot;(\\d{2})&quot; // day of month with leading zeroes (01 - 31)
  679. },
  680. j: {
  681. g:1,
  682. c:&quot;d = parseInt(results[{0}], 10);\n&quot;,
  683. s:&quot;(\\d{1,2})&quot; // day of month without leading zeroes (1 - 31)
  684. },
  685. D: function() {
  686. for (var a = [], i = 0; i &lt; 7; a.push(Date.getShortDayName(i)), ++i); // get localised short day names
  687. return {
  688. g:0,
  689. c:null,
  690. s:&quot;(?:&quot; + a.join(&quot;|&quot;) +&quot;)&quot;
  691. };
  692. },
  693. l: function() {
  694. return {
  695. g:0,
  696. c:null,
  697. s:&quot;(?:&quot; + Date.dayNames.join(&quot;|&quot;) + &quot;)&quot;
  698. };
  699. },
  700. N: {
  701. g:0,
  702. c:null,
  703. s:&quot;[1-7]&quot; // ISO-8601 day number (1 (monday) - 7 (sunday))
  704. },
  705. S: {
  706. g:0,
  707. c:null,
  708. s:&quot;(?:st|nd|rd|th)&quot;
  709. },
  710. w: {
  711. g:0,
  712. c:null,
  713. s:&quot;[0-6]&quot; // javascript day number (0 (sunday) - 6 (saturday))
  714. },
  715. z: {
  716. g:1,
  717. c:&quot;z = parseInt(results[{0}], 10);\n&quot;,
  718. s:&quot;(\\d{1,3})&quot; // day of the year (0 - 364 (365 in leap years))
  719. },
  720. W: {
  721. g:0,
  722. c:null,
  723. s:&quot;(?:\\d{2})&quot; // ISO-8601 week number (with leading zero)
  724. },
  725. F: function() {
  726. return {
  727. g:1,
  728. c:&quot;m = parseInt(Date.getMonthNumber(results[{0}]), 10);\n&quot;, // get localised month number
  729. s:&quot;(&quot; + Date.monthNames.join(&quot;|&quot;) + &quot;)&quot;
  730. };
  731. },
  732. M: function() {
  733. for (var a = [], i = 0; i &lt; 12; a.push(Date.getShortMonthName(i)), ++i); // get localised short month names
  734. return Ext.applyIf({
  735. s:&quot;(&quot; + a.join(&quot;|&quot;) + &quot;)&quot;
  736. }, $f(&quot;F&quot;));
  737. },
  738. m: {
  739. g:1,
  740. c:&quot;m = parseInt(results[{0}], 10) - 1;\n&quot;,
  741. s:&quot;(\\d{2})&quot; // month number with leading zeros (01 - 12)
  742. },
  743. n: {
  744. g:1,
  745. c:&quot;m = parseInt(results[{0}], 10) - 1;\n&quot;,
  746. s:&quot;(\\d{1,2})&quot; // month number without leading zeros (1 - 12)
  747. },
  748. t: {
  749. g:0,
  750. c:null,
  751. s:&quot;(?:\\d{2})&quot; // no. of days in the month (28 - 31)
  752. },
  753. L: {
  754. g:0,
  755. c:null,
  756. s:&quot;(?:1|0)&quot;
  757. },
  758. o: function() {
  759. return $f(&quot;Y&quot;);
  760. },
  761. Y: {
  762. g:1,
  763. c:&quot;y = parseInt(results[{0}], 10);\n&quot;,
  764. s:&quot;(\\d{4})&quot; // 4-digit year
  765. },
  766. y: {
  767. g:1,
  768. c:&quot;var ty = parseInt(results[{0}], 10);\n&quot;
  769. + &quot;y = ty &gt; Date.y2kYear ? 1900 + ty : 2000 + ty;\n&quot;, // 2-digit year
  770. s:&quot;(\\d{1,2})&quot;
  771. },
  772. <span id='Date-method-a'> /**
  773. </span> * In the am/pm parsing routines, we allow both upper and lower case
  774. * even though it doesn't exactly match the spec. It gives much more flexibility
  775. * in being able to specify case insensitive regexes.
  776. */
  777. a: function(){
  778. return $f(&quot;A&quot;);
  779. },
  780. A: {
  781. // We need to calculate the hour before we apply AM/PM when parsing
  782. calcLast: true,
  783. g:1,
  784. c:&quot;if (/(am)/i.test(results[{0}])) {\n&quot;
  785. + &quot;if (!h || h == 12) { h = 0; }\n&quot;
  786. + &quot;} else { if (!h || h &lt; 12) { h = (h || 0) + 12; }}&quot;,
  787. s:&quot;(AM|PM|am|pm)&quot;
  788. },
  789. g: function() {
  790. return $f(&quot;G&quot;);
  791. },
  792. G: {
  793. g:1,
  794. c:&quot;h = parseInt(results[{0}], 10);\n&quot;,
  795. s:&quot;(\\d{1,2})&quot; // 24-hr format of an hour without leading zeroes (0 - 23)
  796. },
  797. h: function() {
  798. return $f(&quot;H&quot;);
  799. },
  800. H: {
  801. g:1,
  802. c:&quot;h = parseInt(results[{0}], 10);\n&quot;,
  803. s:&quot;(\\d{2})&quot; // 24-hr format of an hour with leading zeroes (00 - 23)
  804. },
  805. i: {
  806. g:1,
  807. c:&quot;i = parseInt(results[{0}], 10);\n&quot;,
  808. s:&quot;(\\d{2})&quot; // minutes with leading zeros (00 - 59)
  809. },
  810. s: {
  811. g:1,
  812. c:&quot;s = parseInt(results[{0}], 10);\n&quot;,
  813. s:&quot;(\\d{2})&quot; // seconds with leading zeros (00 - 59)
  814. },
  815. u: {
  816. g:1,
  817. c:&quot;ms = results[{0}]; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n&quot;,
  818. s:&quot;(\\d+)&quot; // decimal fraction of a second (minimum = 1 digit, maximum = unlimited)
  819. },
  820. O: {
  821. g:1,
  822. c:[
  823. &quot;o = results[{0}];&quot;,
  824. &quot;var sn = o.substring(0,1),&quot;, // get + / - sign
  825. &quot;hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60),&quot;, // get hours (performs minutes-to-hour conversion also, just in case)
  826. &quot;mn = o.substring(3,5) % 60;&quot;, // get minutes
  827. &quot;o = ((-12 &lt;= (hr*60 + mn)/60) &amp;&amp; ((hr*60 + mn)/60 &lt;= 14))? (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;\n&quot; // -12hrs &lt;= GMT offset &lt;= 14hrs
  828. ].join(&quot;\n&quot;),
  829. s: &quot;([+\-]\\d{4})&quot; // GMT offset in hrs and mins
  830. },
  831. P: {
  832. g:1,
  833. c:[
  834. &quot;o = results[{0}];&quot;,
  835. &quot;var sn = o.substring(0,1),&quot;, // get + / - sign
  836. &quot;hr = o.substring(1,3)*1 + Math.floor(o.substring(4,6) / 60),&quot;, // get hours (performs minutes-to-hour conversion also, just in case)
  837. &quot;mn = o.substring(4,6) % 60;&quot;, // get minutes
  838. &quot;o = ((-12 &lt;= (hr*60 + mn)/60) &amp;&amp; ((hr*60 + mn)/60 &lt;= 14))? (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;\n&quot; // -12hrs &lt;= GMT offset &lt;= 14hrs
  839. ].join(&quot;\n&quot;),
  840. s: &quot;([+\-]\\d{2}:\\d{2})&quot; // GMT offset in hrs and mins (with colon separator)
  841. },
  842. T: {
  843. g:0,
  844. c:null,
  845. s:&quot;[A-Z]{1,4}&quot; // timezone abbrev. may be between 1 - 4 chars
  846. },
  847. Z: {
  848. g:1,
  849. c:&quot;zz = results[{0}] * 1;\n&quot; // -43200 &lt;= UTC offset &lt;= 50400
  850. + &quot;zz = (-43200 &lt;= zz &amp;&amp; zz &lt;= 50400)? zz : null;\n&quot;,
  851. s:&quot;([+\-]?\\d{1,5})&quot; // leading '+' sign is optional for UTC offset
  852. },
  853. c: function() {
  854. var calc = [],
  855. arr = [
  856. $f(&quot;Y&quot;, 1), // year
  857. $f(&quot;m&quot;, 2), // month
  858. $f(&quot;d&quot;, 3), // day
  859. $f(&quot;h&quot;, 4), // hour
  860. $f(&quot;i&quot;, 5), // minute
  861. $f(&quot;s&quot;, 6), // second
  862. {c:&quot;ms = results[7] || '0'; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n&quot;}, // decimal fraction of a second (minimum = 1 digit, maximum = unlimited)
  863. {c:[ // allow either &quot;Z&quot; (i.e. UTC) or &quot;-0530&quot; or &quot;+08:00&quot; (i.e. UTC offset) timezone delimiters. assumes local timezone if no timezone is specified
  864. &quot;if(results[8]) {&quot;, // timezone specified
  865. &quot;if(results[8] == 'Z'){&quot;,
  866. &quot;zz = 0;&quot;, // UTC
  867. &quot;}else if (results[8].indexOf(':') &gt; -1){&quot;,
  868. $f(&quot;P&quot;, 8).c, // timezone offset with colon separator
  869. &quot;}else{&quot;,
  870. $f(&quot;O&quot;, 8).c, // timezone offset without colon separator
  871. &quot;}&quot;,
  872. &quot;}&quot;
  873. ].join('\n')}
  874. ];
  875. for (var i = 0, l = arr.length; i &lt; l; ++i) {
  876. calc.push(arr[i].c);
  877. }
  878. return {
  879. g:1,
  880. c:calc.join(&quot;&quot;),
  881. s:[
  882. arr[0].s, // year (required)
  883. &quot;(?:&quot;, &quot;-&quot;, arr[1].s, // month (optional)
  884. &quot;(?:&quot;, &quot;-&quot;, arr[2].s, // day (optional)
  885. &quot;(?:&quot;,
  886. &quot;(?:T| )?&quot;, // time delimiter -- either a &quot;T&quot; or a single blank space
  887. arr[3].s, &quot;:&quot;, arr[4].s, // hour AND minute, delimited by a single colon (optional). MUST be preceded by either a &quot;T&quot; or a single blank space
  888. &quot;(?::&quot;, arr[5].s, &quot;)?&quot;, // seconds (optional)
  889. &quot;(?:(?:\\.|,)(\\d+))?&quot;, // decimal fraction of a second (e.g. &quot;,12345&quot; or &quot;.98765&quot;) (optional)
  890. &quot;(Z|(?:[-+]\\d{2}(?::)?\\d{2}))?&quot;, // &quot;Z&quot; (UTC) or &quot;-0530&quot; (UTC offset without colon delimiter) or &quot;+08:00&quot; (UTC offset with colon delimiter) (optional)
  891. &quot;)?&quot;,
  892. &quot;)?&quot;,
  893. &quot;)?&quot;
  894. ].join(&quot;&quot;)
  895. };
  896. },
  897. U: {
  898. g:1,
  899. c:&quot;u = parseInt(results[{0}], 10);\n&quot;,
  900. s:&quot;(-?\\d+)&quot; // leading minus sign indicates seconds before UNIX epoch
  901. }
  902. }
  903. });
  904. }());
  905. Ext.apply(Date.prototype, {
  906. // private
  907. dateFormat : function(format) {
  908. if (Date.formatFunctions[format] == null) {
  909. Date.createFormat(format);
  910. }
  911. return Date.formatFunctions[format].call(this);
  912. },
  913. <span id='Date-method-getTimezone'> /**
  914. </span> * Get the timezone abbreviation of the current date (equivalent to the format specifier 'T').
  915. *
  916. * Note: The date string returned by the javascript Date object's toString() method varies
  917. * between browsers (e.g. FF vs IE) and system region settings (e.g. IE in Asia vs IE in America).
  918. * For a given date string e.g. &quot;Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)&quot;,
  919. * getTimezone() first tries to get the timezone abbreviation from between a pair of parentheses
  920. * (which may or may not be present), failing which it proceeds to get the timezone abbreviation
  921. * from the GMT offset portion of the date string.
  922. * @return {String} The abbreviated timezone name (e.g. 'CST', 'PDT', 'EDT', 'MPST' ...).
  923. */
  924. getTimezone : function() {
  925. // the following list shows the differences between date strings from different browsers on a WinXP SP2 machine from an Asian locale:
  926. //
  927. // Opera : &quot;Thu, 25 Oct 2007 22:53:45 GMT+0800&quot; -- shortest (weirdest) date string of the lot
  928. // Safari : &quot;Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)&quot; -- value in parentheses always gives the correct timezone (same as FF)
  929. // FF : &quot;Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)&quot; -- value in parentheses always gives the correct timezone
  930. // IE : &quot;Thu Oct 25 22:54:35 UTC+0800 2007&quot; -- (Asian system setting) look for 3-4 letter timezone abbrev
  931. // IE : &quot;Thu Oct 25 17:06:37 PDT 2007&quot; -- (American system setting) look for 3-4 letter timezone abbrev
  932. //
  933. // this crazy regex attempts to guess the correct timezone abbreviation despite these differences.
  934. // step 1: (?:\((.*)\) -- find timezone in parentheses
  935. // step 2: ([A-Z]{1,4})(?:[\-+][0-9]{4})?(?: -?\d+)?) -- if nothing was found in step 1, find timezone from timezone offset portion of date string
  936. // step 3: remove all non uppercase characters found in step 1 and 2
  937. return this.toString().replace(/^.* (?:\((.*)\)|([A-Z]{1,4})(?:[\-+][0-9]{4})?(?: -?\d+)?)$/, &quot;$1$2&quot;).replace(/[^A-Z]/g, &quot;&quot;);
  938. },
  939. <span id='Date-method-getGMTOffset'> /**
  940. </span> * Get the offset from GMT of the current date (equivalent to the format specifier 'O').
  941. * @param {Boolean} colon (optional) true to separate the hours and minutes with a colon (defaults to false).
  942. * @return {String} The 4-character offset string prefixed with + or - (e.g. '-0600').
  943. */
  944. getGMTOffset : function(colon) {
  945. return (this.getTimezoneOffset() &gt; 0 ? &quot;-&quot; : &quot;+&quot;)
  946. + String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset()) / 60), 2, &quot;0&quot;)
  947. + (colon ? &quot;:&quot; : &quot;&quot;)
  948. + String.leftPad(Math.abs(this.getTimezoneOffset() % 60), 2, &quot;0&quot;);
  949. },
  950. <span id='Date-method-getDayOfYear'> /**
  951. </span> * Get the numeric day number of the year, adjusted for leap year.
  952. * @return {Number} 0 to 364 (365 in leap years).
  953. */
  954. getDayOfYear: function() {
  955. var num = 0,
  956. d = this.clone(),
  957. m = this.getMonth(),
  958. i;
  959. for (i = 0, d.setDate(1), d.setMonth(0); i &lt; m; d.setMonth(++i)) {
  960. num += d.getDaysInMonth();
  961. }
  962. return num + this.getDate() - 1;
  963. },
  964. <span id='Date-method-getWeekOfYear'> /**
  965. </span> * Get the numeric ISO-8601 week number of the year.
  966. * (equivalent to the format specifier 'W', but without a leading zero).
  967. * @return {Number} 1 to 53
  968. */
  969. getWeekOfYear : function() {
  970. // adapted from http://www.merlyn.demon.co.uk/weekcalc.htm
  971. var ms1d = 864e5, // milliseconds in a day
  972. ms7d = 7 * ms1d; // milliseconds in a week
  973. return function() { // return a closure so constants get calculated only once
  974. var DC3 = Date.UTC(this.getFullYear(), this.getMonth(), this.getDate() + 3) / ms1d, // an Absolute Day Number
  975. AWN = Math.floor(DC3 / 7), // an Absolute Week Number
  976. Wyr = new Date(AWN * ms7d).getUTCFullYear();
  977. return AWN - Math.floor(Date.UTC(Wyr, 0, 7) / ms7d) + 1;
  978. };
  979. }(),
  980. <span id='Date-method-isLeapYear'> /**
  981. </span> * Checks if the current date falls within a leap year.
  982. * @return {Boolean} True if the current date falls within a leap year, false otherwise.
  983. */
  984. isLeapYear : function() {
  985. var year = this.getFullYear();
  986. return !!((year &amp; 3) == 0 &amp;&amp; (year % 100 || (year % 400 == 0 &amp;&amp; year)));
  987. },
  988. <span id='Date-method-getFirstDayOfMonth'> /**
  989. </span> * Get the first day of the current month, adjusted for leap year. The returned value
  990. * is the numeric day index within the week (0-6) which can be used in conjunction with
  991. * the {@link #monthNames} array to retrieve the textual day name.
  992. * Example:
  993. * &lt;pre&gt;&lt;code&gt;
  994. var dt = new Date('1/10/2007');
  995. document.write(Date.dayNames[dt.getFirstDayOfMonth()]); //output: 'Monday'
  996. &lt;/code&gt;&lt;/pre&gt;
  997. * @return {Number} The day number (0-6).
  998. */
  999. getFirstDayOfMonth : function() {
  1000. var day = (this.getDay() - (this.getDate() - 1)) % 7;
  1001. return (day &lt; 0) ? (day + 7) : day;
  1002. },
  1003. <span id='Date-method-getLastDayOfMonth'> /**
  1004. </span> * Get the last day of the current month, adjusted for leap year. The returned value
  1005. * is the numeric day index within the week (0-6) which can be used in conjunction with
  1006. * the {@link #monthNames} array to retrieve the textual day name.
  1007. * Example:
  1008. * &lt;pre&gt;&lt;code&gt;
  1009. var dt = new Date('1/10/2007');
  1010. document.write(Date.dayNames[dt.getLastDayOfMonth()]); //output: 'Wednesday'
  1011. &lt;/code&gt;&lt;/pre&gt;
  1012. * @return {Number} The day number (0-6).
  1013. */
  1014. getLastDayOfMonth : function() {
  1015. return this.getLastDateOfMonth().getDay();
  1016. },
  1017. <span id='Date-method-getFirstDateOfMonth'> /**
  1018. </span> * Get the date of the first day of the month in which this date resides.
  1019. * @return {Date}
  1020. */
  1021. getFirstDateOfMonth : function() {
  1022. return new Date(this.getFullYear(), this.getMonth(), 1);
  1023. },
  1024. <span id='Date-method-getLastDateOfMonth'> /**
  1025. </span> * Get the date of the last day of the month in which this date resides.
  1026. * @return {Date}
  1027. */
  1028. getLastDateOfMonth : function() {
  1029. return new Date(this.getFullYear(), this.getMonth(), this.getDaysInMonth());
  1030. },
  1031. <span id='Date-method-getDaysInMonth'> /**
  1032. </span> * Get the number of days in the current month, adjusted for leap year.
  1033. * @return {Number} The number of days in the month.
  1034. */
  1035. getDaysInMonth: function() {
  1036. var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  1037. return function() { // return a closure for efficiency
  1038. var m = this.getMonth();
  1039. return m == 1 &amp;&amp; this.isLeapYear() ? 29 : daysInMonth[m];
  1040. };
  1041. }(),
  1042. <span id='Date-method-getSuffix'> /**
  1043. </span> * Get the English ordinal suffix of the current day (equivalent to the format specifier 'S').
  1044. * @return {String} 'st, 'nd', 'rd' or 'th'.
  1045. */
  1046. getSuffix : function() {
  1047. switch (this.getDate()) {
  1048. case 1:
  1049. case 21:
  1050. case 31:
  1051. return &quot;st&quot;;
  1052. case 2:
  1053. case 22:
  1054. return &quot;nd&quot;;
  1055. case 3:
  1056. case 23:
  1057. return &quot;rd&quot;;
  1058. default:
  1059. return &quot;th&quot;;
  1060. }
  1061. },
  1062. <span id='Date-method-clone'> /**
  1063. </span> * Creates and returns a new Date instance with the exact same date value as the called instance.
  1064. * Dates are copied and passed by reference, so if a copied date variable is modified later, the original
  1065. * variable will also be changed. When the intention is to create a new variable that will not
  1066. * modify the original instance, you should create a clone.
  1067. *
  1068. * Example of correctly cloning a date:
  1069. * &lt;pre&gt;&lt;code&gt;
  1070. //wrong way:
  1071. var orig = new Date('10/1/2006');
  1072. var copy = orig;
  1073. copy.setDate(5);
  1074. document.write(orig); //returns 'Thu Oct 05 2006'!
  1075. //correct way:
  1076. var orig = new Date('10/1/2006');
  1077. var copy = orig.clone();
  1078. copy.setDate(5);
  1079. document.write(orig); //returns 'Thu Oct 01 2006'
  1080. &lt;/code&gt;&lt;/pre&gt;
  1081. * @return {Date} The new Date instance.
  1082. */
  1083. clone : function() {
  1084. return new Date(this.getTime());
  1085. },
  1086. <span id='Date-method-isDST'> /**
  1087. </span> * Checks if the current date is affected by Daylight Saving Time (DST).
  1088. * @return {Boolean} True if the current date is affected by DST.
  1089. */
  1090. isDST : function() {
  1091. // adapted from http://extjs.com/forum/showthread.php?p=247172#post247172
  1092. // courtesy of @geoffrey.mcgill
  1093. return new Date(this.getFullYear(), 0, 1).getTimezoneOffset() != this.getTimezoneOffset();
  1094. },
  1095. <span id='Date-method-clearTime'> /**
  1096. </span> * Attempts to clear all time information from this Date by setting the time to midnight of the same day,
  1097. * automatically adjusting for Daylight Saving Time (DST) where applicable.
  1098. * (note: DST timezone information for the browser's host operating system is assumed to be up-to-date)
  1099. * @param {Boolean} clone true to create a clone of this date, clear the time and return it (defaults to false).
  1100. * @return {Date} this or the clone.
  1101. */
  1102. clearTime : function(clone) {
  1103. if (clone) {
  1104. return this.clone().clearTime();
  1105. }
  1106. // get current date before clearing time
  1107. var d = this.getDate();
  1108. // clear time
  1109. this.setHours(0);
  1110. this.setMinutes(0);
  1111. this.setSeconds(0);
  1112. this.setMilliseconds(0);
  1113. if (this.getDate() != d) { // account for DST (i.e. day of month changed when setting hour = 0)
  1114. // note: DST adjustments are assumed to occur in multiples of 1 hour (this is almost always the case)
  1115. // refer to http://www.timeanddate.com/time/aboutdst.html for the (rare) exceptions to this rule
  1116. // increment hour until cloned date == current date
  1117. for (var hr = 1, c = this.add(Date.HOUR, hr); c.getDate() != d; hr++, c = this.add(Date.HOUR, hr));
  1118. this.setDate(d);
  1119. this.setHours(c.getHours());
  1120. }
  1121. return this;
  1122. },
  1123. <span id='Date-method-add'> /**
  1124. </span> * Provides a convenient method for performing basic date arithmetic. This method
  1125. * does not modify the Date instance being called - it creates and returns
  1126. * a new Date instance containing the resulting date value.
  1127. *
  1128. * Examples:
  1129. * &lt;pre&gt;&lt;code&gt;
  1130. // Basic usage:
  1131. var dt = new Date('10/29/2006').add(Date.DAY, 5);
  1132. document.write(dt); //returns 'Fri Nov 03 2006 00:00:00'
  1133. // Negative values will be subtracted:
  1134. var dt2 = new Date('10/1/2006').add(Date.DAY, -5);
  1135. document.write(dt2); //returns 'Tue Sep 26 2006 00:00:00'
  1136. // You can even chain several calls together in one line:
  1137. var dt3 = new Date('10/1/2006').add(Date.DAY, 5).add(Date.HOUR, 8).add(Date.MINUTE, -30);
  1138. document.write(dt3); //returns 'Fri Oct 06 2006 07:30:00'
  1139. &lt;/code&gt;&lt;/pre&gt;
  1140. *
  1141. * @param {String} interval A valid date interval enum value.
  1142. * @param {Number} value The amount to add to the current date.
  1143. * @return {Date} The new Date instance.
  1144. */
  1145. add : function(interval, value) {
  1146. var d = this.clone();
  1147. if (!interval || value === 0) return d;
  1148. switch(interval.toLowerCase()) {
  1149. case Date.MILLI:
  1150. d.setMilliseconds(this.getMilliseconds() + value);
  1151. break;
  1152. case Date.SECOND:
  1153. d.setSeconds(this.getSeconds() + value);
  1154. break;
  1155. case Date.MINUTE:
  1156. d.setMinutes(this.getMinutes() + value);
  1157. break;
  1158. case Date.HOUR:
  1159. d.setHours(this.getHours() + value);
  1160. break;
  1161. case Date.DAY:
  1162. d.setDate(this.getDate() + value);
  1163. break;
  1164. case Date.MONTH:
  1165. var day = this.getDate();
  1166. if (day &gt; 28) {
  1167. day = Math.min(day, this.getFirstDateOfMonth().add('mo', value).getLastDateOfMonth().getDate());
  1168. }
  1169. d.setDate(day);
  1170. d.setMonth(this.getMonth() + value);
  1171. break;
  1172. case Date.YEAR:
  1173. d.setFullYear(this.getFullYear() + value);
  1174. break;
  1175. }
  1176. return d;
  1177. },
  1178. <span id='Date-method-between'> /**
  1179. </span> * Checks if this date falls on or between the given start and end dates.
  1180. * @param {Date} start Start date
  1181. * @param {Date} end End date
  1182. * @return {Boolean} true if this date falls on or between the given start and end dates.
  1183. */
  1184. between : function(start, end) {
  1185. var t = this.getTime();
  1186. return start.getTime() &lt;= t &amp;&amp; t &lt;= end.getTime();
  1187. }
  1188. });
  1189. <span id='Date-method-format'>/**
  1190. </span> * Formats a date given the supplied format string.
  1191. * @param {String} format The format string.
  1192. * @return {String} The formatted date.
  1193. * @method format
  1194. */
  1195. Date.prototype.format = Date.prototype.dateFormat;
  1196. // private
  1197. if (Ext.isSafari &amp;&amp; (navigator.userAgent.match(/WebKit\/(\d+)/)[1] || NaN) &lt; 420) {
  1198. Ext.apply(Date.prototype, {
  1199. _xMonth : Date.prototype.setMonth,
  1200. _xDate : Date.prototype.setDate,
  1201. // Bug in Safari 1.3, 2.0 (WebKit build &lt; 420)
  1202. // Date.setMonth does not work consistently if iMonth is not 0-11
  1203. setMonth : function(num) {
  1204. if (num &lt;= -1) {
  1205. var n = Math.ceil(-num),
  1206. back_year = Math.ceil(n / 12),
  1207. month = (n % 12) ? 12 - n % 12 : 0;
  1208. this.setFullYear(this.getFullYear() - back_year);
  1209. return this._xMonth(month);
  1210. } else {
  1211. return this._xMonth(num);
  1212. }
  1213. },
  1214. // Bug in setDate() method (resolved in WebKit build 419.3, so to be safe we target Webkit builds &lt; 420)
  1215. // The parameter for Date.setDate() is converted to a signed byte integer in Safari
  1216. // http://brianary.blogspot.com/2006/03/safari-date-bug.html
  1217. setDate : function(d) {
  1218. // use setTime() to workaround setDate() bug
  1219. // subtract current day of month in milliseconds, then add desired day of month in milliseconds
  1220. return this.setTime(this.getTime() - (this.getDate() - d) * 864e5);
  1221. }
  1222. });
  1223. }
  1224. /* Some basic Date tests... (requires Firebug)
  1225. Date.parseDate('', 'c'); // call Date.parseDate() once to force computation of regex string so we can console.log() it
  1226. console.log('Insane Regex for &quot;c&quot; format: %o', Date.parseCodes.c.s); // view the insane regex for the &quot;c&quot; format specifier
  1227. // standard tests
  1228. console.group('Standard Date.parseDate() Tests');
  1229. console.log('Date.parseDate(&quot;2009-01-05T11:38:56&quot;, &quot;c&quot;) = %o', Date.parseDate(&quot;2009-01-05T11:38:56&quot;, &quot;c&quot;)); // assumes browser's timezone setting
  1230. console.log('Date.parseDate(&quot;2009-02-04T12:37:55.001000&quot;, &quot;c&quot;) = %o', Date.parseDate(&quot;2009-02-04T12:37:55.001000&quot;, &quot;c&quot;)); // assumes browser's timezone setting
  1231. console.log('Date.parseDate(&quot;2009-03-03T13:36:54,101000Z&quot;, &quot;c&quot;) = %o', Date.parseDate(&quot;2009-03-03T13:36:54,101000Z&quot;, &quot;c&quot;)); // UTC
  1232. console.log('Date.parseDate(&quot;2009-04-02T14:35:53.901000-0530&quot;, &quot;c&quot;) = %o', Date.parseDate(&quot;2009-04-02T14:35:53.901000-0530&quot;, &quot;c&quot;)); // GMT-0530
  1233. console.log('Date.parseDate(&quot;2009-05-01T15:34:52,9876000+08:00&quot;, &quot;c&quot;) = %o', Date.parseDate(&quot;2009-05-01T15:34:52,987600+08:00&quot;, &quot;c&quot;)); // GMT+08:00
  1234. console.groupEnd();
  1235. // ISO-8601 format as specified in http://www.w3.org/TR/NOTE-datetime
  1236. // -- accepts ALL 6 levels of date-time granularity
  1237. console.group('ISO-8601 Granularity Test (see http://www.w3.org/TR/NOTE-datetime)');
  1238. console.log('Date.parseDate(&quot;1997&quot;, &quot;c&quot;) = %o', Date.parseDate(&quot;1997&quot;, &quot;c&quot;)); // YYYY (e.g. 1997)
  1239. console.log('Date.parseDate(&quot;1997-07&quot;, &quot;c&quot;) = %o', Date.parseDate(&quot;1997-07&quot;, &quot;c&quot;)); // YYYY-MM (e.g. 1997-07)
  1240. console.log('Date.parseDate(&quot;1997-07-16&quot;, &quot;c&quot;) = %o', Date.parseDate(&quot;1997-07-16&quot;, &quot;c&quot;)); // YYYY-MM-DD (e.g. 1997-07-16)
  1241. console.log('Date.parseDate(&quot;1997-07-16T19:20+01:00&quot;, &quot;c&quot;) = %o', Date.parseDate(&quot;1997-07-16T19:20+01:00&quot;, &quot;c&quot;)); // YYYY-MM-DDThh:mmTZD (e.g. 1997-07-16T19:20+01:00)
  1242. console.log('Date.parseDate(&quot;1997-07-16T19:20:30+01:00&quot;, &quot;c&quot;) = %o', Date.parseDate(&quot;1997-07-16T19:20:30+01:00&quot;, &quot;c&quot;)); // YYYY-MM-DDThh:mm:ssTZD (e.g. 1997-07-16T19:20:30+01:00)
  1243. console.log('Date.parseDate(&quot;1997-07-16T19:20:30.45+01:00&quot;, &quot;c&quot;) = %o', Date.parseDate(&quot;1997-07-16T19:20:30.45+01:00&quot;, &quot;c&quot;)); // YYYY-MM-DDThh:mm:ss.sTZD (e.g. 1997-07-16T19:20:30.45+01:00)
  1244. console.log('Date.parseDate(&quot;1997-07-16 19:20:30.45+01:00&quot;, &quot;c&quot;) = %o', Date.parseDate(&quot;1997-07-16 19:20:30.45+01:00&quot;, &quot;c&quot;)); // YYYY-MM-DD hh:mm:ss.sTZD (e.g. 1997-07-16T19:20:30.45+01:00)
  1245. console.log('Date.parseDate(&quot;1997-13-16T19:20:30.45+01:00&quot;, &quot;c&quot;, true)= %o', Date.parseDate(&quot;1997-13-16T19:20:30.45+01:00&quot;, &quot;c&quot;, true)); // strict date parsing with invalid month value
  1246. console.groupEnd();
  1247. */
  1248. </pre>
  1249. </body>
  1250. </html>