DateTimeFormatInfo.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. // System.Globalization.DateTimeFormatInfo
  2. //
  3. // Some useful functions are missing in the ECMA specs.
  4. // They have been added following MS SDK Beta2
  5. //
  6. // Martin Weindel ([email protected])
  7. //
  8. // (C) Martin Weindel ([email protected])
  9. //
  10. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. using System;
  32. using System.Collections;
  33. using System.Threading;
  34. namespace System.Globalization
  35. {
  36. [Serializable]
  37. [MonoTODO ("Fix serialization compatibility with MS.NET")]
  38. public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider {
  39. private static readonly string MSG_READONLY = "This instance is read only";
  40. private static readonly string MSG_ARRAYSIZE_MONTH = "An array with exactly 13 elements is needed";
  41. private static readonly string MSG_ARRAYSIZE_DAY = "An array with exactly 7 elements is needed";
  42. private static readonly string[] INVARIANT_ABBREVIATED_DAY_NAMES
  43. = new string[7] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
  44. private static readonly string[] INVARIANT_DAY_NAMES
  45. = new string[7] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
  46. private static readonly string[] INVARIANT_ABBREVIATED_MONTH_NAMES
  47. = new string[13] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""};
  48. private static readonly string[] INVARIANT_MONTH_NAMES
  49. = new string[13] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", ""};
  50. private static readonly string[] INVARIANT_ERA_NAMES = {"A.D."};
  51. private static DateTimeFormatInfo theInvariantDateTimeFormatInfo;
  52. private bool readOnly;
  53. private string _AMDesignator;
  54. private string _PMDesignator;
  55. private string _DateSeparator;
  56. private string _TimeSeparator;
  57. private string _ShortDatePattern;
  58. private string _LongDatePattern;
  59. private string _ShortTimePattern;
  60. private string _LongTimePattern;
  61. private string _MonthDayPattern;
  62. private string _YearMonthPattern;
  63. private string _FullDateTimePattern;
  64. private string _RFC1123Pattern;
  65. private string _SortableDateTimePattern;
  66. private string _UniversalSortableDateTimePattern;
  67. private DayOfWeek _FirstDayOfWeek;
  68. private Calendar _Calendar;
  69. private CalendarWeekRule _CalendarWeekRule;
  70. private string[] _AbbreviatedDayNames;
  71. private string[] _DayNames;
  72. private string[] _MonthNames;
  73. private string[] _AbbreviatedMonthNames;
  74. // FIXME: not supported other than invariant
  75. private string [] _ShortDatePatterns;
  76. private string [] _LongDatePatterns;
  77. private string [] _ShortTimePatterns;
  78. private string [] _LongTimePatterns;
  79. private string [] _MonthDayPatterns;
  80. private string [] _YearMonthPatterns;
  81. public DateTimeFormatInfo()
  82. {
  83. readOnly = false;
  84. _AMDesignator = "AM";
  85. _PMDesignator = "PM";
  86. _DateSeparator = "/";
  87. _TimeSeparator = ":";
  88. _ShortDatePattern = "MM/dd/yyyy";
  89. _LongDatePattern = "dddd, dd MMMM yyyy";
  90. _ShortTimePattern = "HH:mm";
  91. _LongTimePattern = "HH:mm:ss";
  92. _MonthDayPattern = "MMMM dd";
  93. _YearMonthPattern = "yyyy MMMM";
  94. _FullDateTimePattern = "dddd, dd MMMM yyyy HH:mm:ss";
  95. // FIXME: for the following three pattern: "The
  96. // default value of this property is derived
  97. // from the calendar that is set for
  98. // CultureInfo.CurrentCulture or the default
  99. // calendar of CultureInfo.CurrentCulture."
  100. // Actually, no predefined culture has different values
  101. // than those default values.
  102. _RFC1123Pattern = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'";
  103. _SortableDateTimePattern = "yyyy'-'MM'-'dd'T'HH':'mm':'ss";
  104. _UniversalSortableDateTimePattern = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'";
  105. _FirstDayOfWeek = DayOfWeek.Sunday;
  106. _Calendar = new GregorianCalendar();
  107. _CalendarWeekRule = CalendarWeekRule.FirstDay;
  108. _AbbreviatedDayNames = INVARIANT_ABBREVIATED_DAY_NAMES;
  109. _DayNames = INVARIANT_DAY_NAMES;
  110. _AbbreviatedMonthNames = INVARIANT_ABBREVIATED_MONTH_NAMES;
  111. _MonthNames = INVARIANT_MONTH_NAMES;
  112. }
  113. // LAMESPEC: this is not in ECMA specs
  114. public static DateTimeFormatInfo GetInstance(IFormatProvider provider)
  115. {
  116. if (provider != null) {
  117. DateTimeFormatInfo dtfi;
  118. dtfi = (DateTimeFormatInfo)provider.GetFormat(typeof(DateTimeFormatInfo));
  119. if (dtfi != null)
  120. return dtfi;
  121. }
  122. return CurrentInfo;
  123. }
  124. public bool IsReadOnly {
  125. get {
  126. return readOnly;
  127. }
  128. }
  129. public static DateTimeFormatInfo ReadOnly(DateTimeFormatInfo dtfi)
  130. {
  131. DateTimeFormatInfo copy = (DateTimeFormatInfo)dtfi.Clone();
  132. copy.readOnly = true;
  133. return copy;
  134. }
  135. public object Clone ()
  136. {
  137. DateTimeFormatInfo clone = (DateTimeFormatInfo) MemberwiseClone();
  138. // clone is not read only
  139. clone.readOnly = false;
  140. return clone;
  141. }
  142. public object GetFormat(Type formatType)
  143. {
  144. return (formatType == GetType()) ? this : null;
  145. }
  146. [MonoTODO]
  147. public string GetAbbreviatedEraName(int era)
  148. {
  149. if (era < _Calendar.Eras.Length || era >= _Calendar.Eras.Length)
  150. throw new ArgumentOutOfRangeException();
  151. notImplemented();
  152. //FIXME: implement me
  153. return null;
  154. }
  155. public string GetAbbreviatedMonthName(int month)
  156. {
  157. if (month < 1 || month > 13) throw new ArgumentOutOfRangeException();
  158. return _AbbreviatedMonthNames[month-1];
  159. }
  160. [MonoTODO]
  161. public int GetEra(string eraName)
  162. {
  163. if (eraName == null) throw new ArgumentNullException();
  164. eraName = eraName.ToUpper();
  165. notImplemented();
  166. //FIXME: implement me
  167. return -1;
  168. }
  169. [MonoTODO]
  170. public string GetEraName(int era)
  171. {
  172. // if (era < _Calendar.Eras.Length || era >= _Calendar.Eras.Length)
  173. // throw new ArgumentOutOfRangeException();
  174. try {
  175. return INVARIANT_ERA_NAMES[era - 1];
  176. }
  177. catch {
  178. //FIXME: implement me
  179. notImplemented();
  180. return null;
  181. }
  182. }
  183. public string GetMonthName(int month)
  184. {
  185. if (month < 1 || month > 13) throw new ArgumentOutOfRangeException();
  186. return _MonthNames[month-1];
  187. }
  188. public string[] AbbreviatedDayNames
  189. {
  190. get
  191. {
  192. return (string[]) _AbbreviatedDayNames.Clone();
  193. }
  194. set
  195. {
  196. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  197. if (value == null) throw new ArgumentNullException();
  198. if (value.GetLength(0) != 7) throw new ArgumentException(MSG_ARRAYSIZE_DAY);
  199. _AbbreviatedDayNames = (string[]) value.Clone();
  200. }
  201. }
  202. public string[] AbbreviatedMonthNames
  203. {
  204. get
  205. {
  206. return (string[]) _AbbreviatedMonthNames.Clone();
  207. }
  208. set
  209. {
  210. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  211. if (value == null) throw new ArgumentNullException();
  212. if (value.GetLength(0) != 13) throw new ArgumentException(MSG_ARRAYSIZE_MONTH);
  213. _AbbreviatedMonthNames = (string[]) value.Clone();
  214. }
  215. }
  216. public string[] DayNames
  217. {
  218. get
  219. {
  220. return (string[]) _DayNames.Clone();
  221. }
  222. set
  223. {
  224. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  225. if (value == null) throw new ArgumentNullException();
  226. if (value.GetLength(0) != 7) throw new ArgumentException(MSG_ARRAYSIZE_DAY);
  227. _DayNames = (string[]) value.Clone();
  228. }
  229. }
  230. public string[] MonthNames
  231. {
  232. get
  233. {
  234. return (string[]) _MonthNames.Clone();
  235. }
  236. set
  237. {
  238. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  239. if (value == null) throw new ArgumentNullException();
  240. if (value.GetLength(0) != 13) throw new ArgumentException(MSG_ARRAYSIZE_MONTH);
  241. _MonthNames = (string[]) value.Clone();
  242. }
  243. }
  244. public string AMDesignator
  245. {
  246. get
  247. {
  248. return _AMDesignator;
  249. }
  250. set
  251. {
  252. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  253. if (value == null) throw new ArgumentNullException();
  254. _AMDesignator = value;
  255. }
  256. }
  257. public string PMDesignator
  258. {
  259. get
  260. {
  261. return _PMDesignator;
  262. }
  263. set
  264. {
  265. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  266. if (value == null) throw new ArgumentNullException();
  267. _PMDesignator = value;
  268. }
  269. }
  270. public string DateSeparator
  271. {
  272. get
  273. {
  274. return _DateSeparator;
  275. }
  276. set
  277. {
  278. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  279. if (value == null) throw new ArgumentNullException();
  280. _DateSeparator = value;
  281. }
  282. }
  283. public string TimeSeparator
  284. {
  285. get
  286. {
  287. return _TimeSeparator;
  288. }
  289. set
  290. {
  291. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  292. if (value == null) throw new ArgumentNullException();
  293. _TimeSeparator = value;
  294. }
  295. }
  296. public string LongDatePattern
  297. {
  298. get
  299. {
  300. return _LongDatePattern;
  301. }
  302. set
  303. {
  304. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  305. if (value == null) throw new ArgumentNullException();
  306. _LongDatePattern = value;
  307. }
  308. }
  309. public string ShortDatePattern
  310. {
  311. get
  312. {
  313. return _ShortDatePattern;
  314. }
  315. set
  316. {
  317. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  318. if (value == null) throw new ArgumentNullException();
  319. _ShortDatePattern = value;
  320. }
  321. }
  322. public string ShortTimePattern
  323. {
  324. get
  325. {
  326. return _ShortTimePattern;
  327. }
  328. set
  329. {
  330. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  331. if (value == null) throw new ArgumentNullException();
  332. _ShortTimePattern = value;
  333. }
  334. }
  335. public string LongTimePattern
  336. {
  337. get
  338. {
  339. return _LongTimePattern;
  340. }
  341. set
  342. {
  343. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  344. if (value == null) throw new ArgumentNullException();
  345. _LongTimePattern = value;
  346. }
  347. }
  348. public string MonthDayPattern
  349. {
  350. get
  351. {
  352. return _MonthDayPattern;
  353. }
  354. set
  355. {
  356. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  357. if (value == null) throw new ArgumentNullException();
  358. _MonthDayPattern = value;
  359. }
  360. }
  361. public string YearMonthPattern
  362. {
  363. get
  364. {
  365. return _YearMonthPattern;
  366. }
  367. set
  368. {
  369. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  370. if (value == null) throw new ArgumentNullException();
  371. _YearMonthPattern = value;
  372. }
  373. }
  374. public string FullDateTimePattern
  375. {
  376. get
  377. {
  378. if(_FullDateTimePattern!=null) {
  379. return _FullDateTimePattern;
  380. } else {
  381. return(_LongDatePattern + " " + _LongTimePattern);
  382. }
  383. }
  384. set
  385. {
  386. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  387. if (value == null) throw new ArgumentNullException();
  388. _FullDateTimePattern = value;
  389. }
  390. }
  391. public static DateTimeFormatInfo CurrentInfo
  392. {
  393. get
  394. {
  395. return Thread.CurrentThread.CurrentCulture.DateTimeFormat;
  396. }
  397. }
  398. public static DateTimeFormatInfo InvariantInfo
  399. {
  400. get
  401. {
  402. if (theInvariantDateTimeFormatInfo == null) {
  403. theInvariantDateTimeFormatInfo =
  404. DateTimeFormatInfo.ReadOnly(new DateTimeFormatInfo());
  405. theInvariantDateTimeFormatInfo.FillInvariantPatterns ();
  406. }
  407. return theInvariantDateTimeFormatInfo;
  408. }
  409. }
  410. // LAMESPEC: this is not in ECMA specs
  411. public DayOfWeek FirstDayOfWeek
  412. {
  413. get
  414. {
  415. return _FirstDayOfWeek;
  416. }
  417. set
  418. {
  419. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  420. if ((int) value < 0 || (int) value > 6) throw new ArgumentOutOfRangeException();
  421. _FirstDayOfWeek = value;
  422. }
  423. }
  424. // LAMESPEC: this is not in ECMA specs
  425. public Calendar Calendar
  426. {
  427. get
  428. {
  429. return _Calendar;
  430. }
  431. set
  432. {
  433. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  434. if (value == null) throw new ArgumentNullException();
  435. _Calendar = value;
  436. }
  437. }
  438. public CalendarWeekRule CalendarWeekRule
  439. {
  440. get
  441. {
  442. return _CalendarWeekRule;
  443. }
  444. set
  445. {
  446. if (IsReadOnly) throw new InvalidOperationException(MSG_READONLY);
  447. _CalendarWeekRule = value;
  448. }
  449. }
  450. // LAMESPEC: this is not in ECMA specs
  451. public string RFC1123Pattern
  452. {
  453. get
  454. {
  455. return _RFC1123Pattern;
  456. }
  457. }
  458. // LAMESPEC: this is not in ECMA specs
  459. public string SortableDateTimePattern
  460. {
  461. get
  462. {
  463. return _SortableDateTimePattern;
  464. }
  465. }
  466. // LAMESPEC: this is not in ECMA specs
  467. public string UniversalSortableDateTimePattern
  468. {
  469. get
  470. {
  471. return _UniversalSortableDateTimePattern;
  472. }
  473. }
  474. // LAMESPEC: this is not in ECMA specs
  475. [MonoTODO ("Not complete depending on GetAllDateTimePatterns(char)")]
  476. public string[] GetAllDateTimePatterns()
  477. {
  478. ArrayList al = new ArrayList ();
  479. foreach (string s in GetAllDateTimePatterns ('d'))
  480. al.Add (s);
  481. foreach (string s in GetAllDateTimePatterns ('D'))
  482. al.Add (s);
  483. foreach (string s in GetAllDateTimePatterns ('g'))
  484. al.Add (s);
  485. foreach (string s in GetAllDateTimePatterns ('G'))
  486. al.Add (s);
  487. foreach (string s in GetAllDateTimePatterns ('f'))
  488. al.Add (s);
  489. foreach (string s in GetAllDateTimePatterns ('F'))
  490. al.Add (s);
  491. // Yes, that is very meaningless, but that is what MS
  492. // is doing (LAMESPEC: Since it is documented that
  493. // 'M' and 'm' are equal, they should not cosider
  494. // that there is a possibility that 'M' and 'm' are
  495. // different.)
  496. foreach (string s in GetAllDateTimePatterns ('m'))
  497. al.Add (s);
  498. foreach (string s in GetAllDateTimePatterns ('M'))
  499. al.Add (s);
  500. foreach (string s in GetAllDateTimePatterns ('r'))
  501. al.Add (s);
  502. foreach (string s in GetAllDateTimePatterns ('R'))
  503. al.Add (s);
  504. foreach (string s in GetAllDateTimePatterns ('s'))
  505. al.Add (s);
  506. foreach (string s in GetAllDateTimePatterns ('t'))
  507. al.Add (s);
  508. foreach (string s in GetAllDateTimePatterns ('T'))
  509. al.Add (s);
  510. foreach (string s in GetAllDateTimePatterns ('u'))
  511. al.Add (s);
  512. foreach (string s in GetAllDateTimePatterns ('U'))
  513. al.Add (s);
  514. foreach (string s in GetAllDateTimePatterns ('y'))
  515. al.Add (s);
  516. foreach (string s in GetAllDateTimePatterns ('Y'))
  517. al.Add (s);
  518. return al.ToArray (typeof (string)) as string [];
  519. }
  520. // LAMESPEC: this is not in ECMA specs
  521. [MonoTODO ("Currently we does not support multiple patterns for other than invariant")]
  522. public string[] GetAllDateTimePatterns (char format)
  523. {
  524. string [] list;
  525. switch (format) {
  526. // Date
  527. case 'D':
  528. if (_LongDatePatterns != null)
  529. return _LongDatePatterns.Clone () as string [];
  530. return new string [] {LongDatePattern};
  531. case 'd':
  532. if (_ShortDatePatterns != null)
  533. return _ShortDatePatterns.Clone () as string [];
  534. return new string [] {ShortDatePattern};
  535. // Time
  536. case 'T':
  537. if (_LongTimePatterns != null)
  538. return _LongTimePatterns.Clone () as string [];
  539. return new string [] {LongTimePattern};
  540. case 't':
  541. if (_ShortTimePatterns != null)
  542. return _ShortTimePatterns.Clone () as string [];
  543. return new string [] {ShortTimePattern};
  544. // {Short|Long}Date + {Short|Long}Time
  545. // FIXME: they should be the agglegation of the
  546. // combination of the Date patterns and Time patterns.
  547. case 'G':
  548. list = PopulateCombinedList (_ShortDatePatterns, _LongTimePatterns);
  549. if (list != null)
  550. return list;
  551. return new string [] {ShortDatePattern + ' ' + LongTimePattern};
  552. case 'g':
  553. list = PopulateCombinedList (_ShortDatePatterns, _ShortTimePatterns);
  554. if (list != null)
  555. return list;
  556. return new string [] {ShortDatePattern + ' ' + ShortTimePattern};
  557. // The 'U' pattern strings are always the same as 'F'.
  558. // (only differs in assuming UTC or not.)
  559. case 'U':
  560. case 'F':
  561. list = PopulateCombinedList (_LongDatePatterns, _LongTimePatterns);
  562. if (list != null)
  563. return list;
  564. return new string [] {LongDatePattern + ' ' + LongTimePattern};
  565. case 'f':
  566. list = PopulateCombinedList (_LongDatePatterns, _ShortTimePatterns);
  567. if (list != null)
  568. return list;
  569. return new string [] {LongDatePattern + ' ' + ShortTimePattern};
  570. // MonthDay
  571. case 'm':
  572. case 'M':
  573. if (_MonthDayPatterns != null)
  574. return _MonthDayPatterns.Clone () as string [];
  575. return new string [] {MonthDayPattern};
  576. // YearMonth
  577. case 'Y':
  578. case 'y':
  579. if (_YearMonthPatterns != null)
  580. return _YearMonthPatterns.Clone () as string [];
  581. return new string [] {YearMonthPattern};
  582. // RFC1123
  583. case 'r':
  584. case 'R':
  585. return new string [] {RFC1123Pattern};
  586. case 's':
  587. return new string [] {SortableDateTimePattern};
  588. case 'u':
  589. return new string [] {UniversalSortableDateTimePattern};
  590. }
  591. throw new ArgumentException ("Format specifier was invalid.");
  592. }
  593. // LAMESPEC: this is not in ECMA specs
  594. public string GetDayName(DayOfWeek dayofweek)
  595. {
  596. int index = (int) dayofweek;
  597. if (index < 0 || index > 6) throw new ArgumentOutOfRangeException();
  598. return _DayNames[index];
  599. }
  600. // LAMESPEC: this is not in ECMA specs
  601. public string GetAbbreviatedDayName(DayOfWeek dayofweek)
  602. {
  603. int index = (int) dayofweek;
  604. if (index < 0 || index > 6) throw new ArgumentOutOfRangeException();
  605. return _AbbreviatedDayNames[index];
  606. }
  607. private void FillInvariantPatterns ()
  608. {
  609. _ShortDatePatterns = new string [] {"MM/dd/yyyy"};
  610. _LongDatePatterns = new string [] {"dddd, dd MMMM yyyy"};
  611. _LongTimePatterns = new string [] {"HH:mm:ss"};
  612. _ShortTimePatterns = new string [] {
  613. "HH:mm",
  614. "hh:mm tt",
  615. "H:mm",
  616. "h:mm tt"
  617. };
  618. _MonthDayPatterns = new string [] {"MMMM dd"};
  619. _YearMonthPatterns = new string [] {"yyyy MMMM"};
  620. }
  621. private string [] PopulateCombinedList (string [] dates, string [] times)
  622. {
  623. if (dates != null && times != null) {
  624. string [] list = new string [dates.Length * times.Length];
  625. int i = 0;
  626. foreach (string d in dates)
  627. foreach (string t in times)
  628. list [i++] = d + ' ' + t;
  629. return list;
  630. }
  631. return null;
  632. }
  633. private static void notImplemented()
  634. {
  635. throw new Exception("Not implemented");
  636. }
  637. }
  638. }