2 // DateTimeFormatEntry.cs
5 // Jackson Harper (jackson@ximian.com)
6 // Marek Safar <marek.safar@gmail.com>
8 // (C) 2004, Novell, Inc (http://www.novell.com)
9 // Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System
.Collections
.Generic
;
35 namespace Mono
.Tools
.LocaleBuilder
37 public class DateTimeFormatEntry
: Entry
39 public string NativeCalendarName
;
40 public string[] AbbreviatedDayNames
= new string[Constants
.NUM_DAYS
];
41 // Input data are mostly missing for abbreviated month but datetime 'MMM' parse depends on them
42 // we pre-fill them the most common ones
43 public string[] AbbreviatedMonthGenitiveNames
= new string[Constants
.NUM_MONTHS
] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", null }
;
44 public string[] AbbreviatedMonthNames
= new string[Constants
.NUM_MONTHS
] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", null }
;
45 public string AMDesignator
;
46 public int? CalendarWeekRule
;
47 public string DateSeparator
;
48 public string[] DayNames
= new string[Constants
.NUM_DAYS
];
49 public int? FirstDayOfWeek
;
50 public string RawFullDateTimePattern
;
51 public string MonthDayPattern
;
52 public string[] MonthGenitiveNames
= new string[Constants
.NUM_MONTHS
];
53 public string[] MonthNames
= new string[Constants
.NUM_MONTHS
];
54 public string PMDesignator
;
55 public string TimeSeparator
;
56 public string[] ShortDatePatterns
= new string[Constants
.NUM_SHORT_DATE_PATTERNS
];
57 public string[] LongDatePatterns
= new string[Constants
.NUM_LONG_DATE_PATTERNS
];
58 public string[] ShortTimePatterns
= new string[Constants
.NUM_SHORT_TIME_PATTERNS
];
59 public string[] LongTimePatterns
= new string[Constants
.NUM_LONG_TIME_PATTERNS
];
60 public string[] ShortestDayNames
= new string[Constants
.NUM_DAYS
];
61 public string[] YearMonthPatterns
= new string[Constants
.NUM_YEAR_MONTH_PATTERNS
];
65 public void AppendTableRow (StringBuilder builder
)
67 builder
.Append ("\t{");
68 builder
.Append (EncodePatternStringIdx (MonthDayPattern
) + ", ");
70 builder
.Append (EncodeStringIdx (AMDesignator
) + ", ");
71 builder
.Append (EncodeStringIdx (PMDesignator
) + ", ");
73 AppendNames (builder
, DayNames
).Append (", ");
74 AppendNames (builder
, AbbreviatedDayNames
).Append (", ");
75 AppendNames (builder
, ShortestDayNames
).Append (", ");
77 AppendNames (builder
, MonthNames
).Append (", ");
78 AppendNames (builder
, MonthGenitiveNames
).Append (", ");
79 AppendNames (builder
, AbbreviatedMonthNames
).Append (", ");
80 AppendNames (builder
, AbbreviatedMonthGenitiveNames
).Append (", ");
83 builder
.Append ((CalendarWeekRule
?? 0) + ", ");
84 builder
.Append ((FirstDayOfWeek
?? 0) + ", ");
86 builder
.Append (EncodeStringIdx (DateSeparator
) + ", ");
87 builder
.Append (EncodeStringIdx (TimeSeparator
) + ", ");
89 AppendPatterns (builder
, ShortDatePatterns
);
91 AppendPatterns (builder
, LongDatePatterns
);
93 AppendPatterns (builder
, ShortTimePatterns
);
95 AppendPatterns (builder
, LongTimePatterns
);
97 AppendPatterns (builder
, YearMonthPatterns
);
102 private void AppendPatterns (StringBuilder builder
, IList
<string> patterns
)
104 builder
.Append ('{');
105 for (int i
= 0; i
< patterns
.Count
; i
++) {
107 builder
.Append (',');
109 string s
= EncodePatternStringIdx (patterns
[i
]);
112 if (patterns
.Count
== 0)
113 builder
.Append ('0');
114 builder
.Append ('}');
117 public override string ToString ()
119 StringBuilder builder
= new StringBuilder ();
120 AppendTableRow (builder
);
121 return builder
.ToString ();