Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CalendarData.cs
Go to the documentation of this file.
3using System.Text;
5
7
8internal sealed class CalendarData
9{
10 private struct IcuEnumCalendarsData
11 {
13
14 public bool DisallowDuplicates;
15 }
16
17 private struct EnumData
18 {
19 public string userOverride;
20
22 }
23
25 {
26 public int userOverride;
27
29 }
30
31 internal string sNativeName;
32
33 internal string[] saShortDates;
34
35 internal string[] saYearMonths;
36
37 internal string[] saLongDates;
38
39 internal string sMonthDay;
40
41 internal string[] saEraNames;
42
43 internal string[] saAbbrevEraNames;
44
45 internal string[] saAbbrevEnglishEraNames;
46
47 internal string[] saDayNames;
48
49 internal string[] saAbbrevDayNames;
50
51 internal string[] saSuperShortDayNames;
52
53 internal string[] saMonthNames;
54
55 internal string[] saAbbrevMonthNames;
56
57 internal string[] saMonthGenitiveNames;
58
59 internal string[] saAbbrevMonthGenitiveNames;
60
61 internal string[] saLeapYearMonthNames;
62
63 internal int iTwoDigitYearMax = 2029;
64
65 private int iCurrentEra;
66
67 internal bool bUseUserOverrides;
68
69 internal static readonly CalendarData Invariant = CreateInvariant();
70
71 private CalendarData()
72 {
73 }
74
76 {
78 calendarData.sNativeName = "Gregorian Calendar";
79 calendarData.iTwoDigitYearMax = 2029;
80 calendarData.iCurrentEra = 1;
81 calendarData.saShortDates = new string[2] { "MM/dd/yyyy", "yyyy-MM-dd" };
82 calendarData.saLongDates = new string[1] { "dddd, dd MMMM yyyy" };
83 calendarData.saYearMonths = new string[1] { "yyyy MMMM" };
84 calendarData.sMonthDay = "MMMM dd";
85 calendarData.saEraNames = new string[1] { "A.D." };
86 calendarData.saAbbrevEraNames = new string[1] { "AD" };
87 calendarData.saAbbrevEnglishEraNames = new string[1] { "AD" };
88 calendarData.saDayNames = new string[7] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
89 calendarData.saAbbrevDayNames = new string[7] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
90 calendarData.saSuperShortDayNames = new string[7] { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" };
91 calendarData.saMonthNames = new string[13]
92 {
93 "January",
94 "February",
95 "March",
96 "April",
97 "May",
98 "June",
99 "July",
100 "August",
101 "September",
102 "October",
103 "November",
104 "December",
105 string.Empty
106 };
107 calendarData.saAbbrevMonthNames = new string[13]
108 {
109 "Jan",
110 "Feb",
111 "Mar",
112 "Apr",
113 "May",
114 "Jun",
115 "Jul",
116 "Aug",
117 "Sep",
118 "Oct",
119 "Nov",
120 "Dec",
121 string.Empty
122 };
123 calendarData.saMonthGenitiveNames = calendarData.saMonthNames;
124 calendarData.saAbbrevMonthGenitiveNames = calendarData.saAbbrevMonthNames;
125 calendarData.saLeapYearMonthNames = calendarData.saMonthNames;
126 calendarData.bUseUserOverrides = false;
127 return calendarData;
128 }
129
131 {
132 this.bUseUserOverrides = bUseUserOverrides;
134 {
135 if (sNativeName == null)
136 {
137 sNativeName = string.Empty;
138 }
139 if (saShortDates == null)
140 {
141 saShortDates = Invariant.saShortDates;
142 }
143 if (saYearMonths == null)
144 {
145 saYearMonths = Invariant.saYearMonths;
146 }
147 if (saLongDates == null)
148 {
149 saLongDates = Invariant.saLongDates;
150 }
151 if (sMonthDay == null)
152 {
153 sMonthDay = Invariant.sMonthDay;
154 }
155 if (saEraNames == null)
156 {
157 saEraNames = Invariant.saEraNames;
158 }
159 if (saAbbrevEraNames == null)
160 {
161 saAbbrevEraNames = Invariant.saAbbrevEraNames;
162 }
163 if (saAbbrevEnglishEraNames == null)
164 {
165 saAbbrevEnglishEraNames = Invariant.saAbbrevEnglishEraNames;
166 }
167 if (saDayNames == null)
168 {
169 saDayNames = Invariant.saDayNames;
170 }
171 if (saAbbrevDayNames == null)
172 {
173 saAbbrevDayNames = Invariant.saAbbrevDayNames;
174 }
175 if (saSuperShortDayNames == null)
176 {
177 saSuperShortDayNames = Invariant.saSuperShortDayNames;
178 }
179 if (saMonthNames == null)
180 {
181 saMonthNames = Invariant.saMonthNames;
182 }
183 if (saAbbrevMonthNames == null)
184 {
185 saAbbrevMonthNames = Invariant.saAbbrevMonthNames;
186 }
187 }
188 if (calendarId == CalendarId.TAIWAN)
189 {
191 {
192 sNativeName = "中華民國曆";
193 }
194 else
195 {
196 sNativeName = string.Empty;
197 }
198 }
199 if (saMonthGenitiveNames == null || saMonthGenitiveNames.Length == 0 || string.IsNullOrEmpty(saMonthGenitiveNames[0]))
200 {
202 }
203 if (saAbbrevMonthGenitiveNames == null || saAbbrevMonthGenitiveNames.Length == 0 || string.IsNullOrEmpty(saAbbrevMonthGenitiveNames[0]))
204 {
206 }
207 if (saLeapYearMonthNames == null || saLeapYearMonthNames.Length == 0 || string.IsNullOrEmpty(saLeapYearMonthNames[0]))
208 {
210 }
213 if (calendarId == CalendarId.JAPAN)
214 {
216 }
217 else
218 {
219 saAbbrevEnglishEraNames = new string[1] { "" };
220 }
221 iCurrentEra = saEraNames.Length;
222 }
223
225 {
226 switch (calendarId)
227 {
228 case CalendarId.GREGORIAN:
229 if (saEraNames == null || saEraNames.Length == 0 || string.IsNullOrEmpty(saEraNames[0]))
230 {
231 saEraNames = new string[1] { "A.D." };
232 }
233 break;
234 case CalendarId.GREGORIAN_US:
235 case CalendarId.JULIAN:
236 saEraNames = new string[1] { "A.D." };
237 break;
238 case CalendarId.HEBREW:
239 saEraNames = new string[1] { "C.E." };
240 break;
241 case CalendarId.HIJRI:
242 case CalendarId.UMALQURA:
243 if (localeName == "dv-MV")
244 {
245 saEraNames = new string[1] { "ހ\u07a8ޖ\u07b0ރ\u07a9" };
246 }
247 else
248 {
249 saEraNames = new string[1] { "بعد الهجرة" };
250 }
251 break;
252 case CalendarId.GREGORIAN_ARABIC:
253 case CalendarId.GREGORIAN_XLIT_ENGLISH:
254 case CalendarId.GREGORIAN_XLIT_FRENCH:
255 saEraNames = new string[1] { "م" };
256 break;
257 case CalendarId.GREGORIAN_ME_FRENCH:
258 saEraNames = new string[1] { "ap. J.-C." };
259 break;
260 case CalendarId.TAIWAN:
262 {
263 saEraNames = new string[1] { "中華民國" };
264 }
265 else
266 {
267 saEraNames = new string[1] { string.Empty };
268 }
269 break;
270 case CalendarId.KOREA:
271 saEraNames = new string[1] { "단기" };
272 break;
273 case CalendarId.THAI:
274 saEraNames = new string[1] { "พ.ศ." };
275 break;
276 case CalendarId.JAPAN:
277 case CalendarId.JAPANESELUNISOLAR:
279 break;
280 case CalendarId.PERSIAN:
281 if (saEraNames == null || saEraNames.Length == 0 || string.IsNullOrEmpty(saEraNames[0]))
282 {
283 saEraNames = new string[1] { "ه.ش" };
284 }
285 break;
286 default:
287 saEraNames = Invariant.saEraNames;
288 break;
289 }
290 }
291
293 {
294 switch (calendarId)
295 {
296 case CalendarId.GREGORIAN:
297 if (saAbbrevEraNames == null || saAbbrevEraNames.Length == 0 || string.IsNullOrEmpty(saAbbrevEraNames[0]))
298 {
299 saAbbrevEraNames = new string[1] { "AD" };
300 }
301 break;
302 case CalendarId.GREGORIAN_US:
303 case CalendarId.JULIAN:
304 saAbbrevEraNames = new string[1] { "AD" };
305 break;
306 case CalendarId.JAPAN:
307 case CalendarId.JAPANESELUNISOLAR:
309 break;
310 case CalendarId.HIJRI:
311 case CalendarId.UMALQURA:
312 if (localeName == "dv-MV")
313 {
314 saAbbrevEraNames = new string[1] { "ހ." };
315 }
316 else
317 {
318 saAbbrevEraNames = new string[1] { "هـ" };
319 }
320 break;
321 case CalendarId.TAIWAN:
322 saAbbrevEraNames = new string[1];
323 if (saEraNames[0].Length == 4)
324 {
325 saAbbrevEraNames[0] = saEraNames[0].Substring(2, 2);
326 }
327 else
328 {
330 }
331 break;
332 case CalendarId.PERSIAN:
333 if (saAbbrevEraNames == null || saAbbrevEraNames.Length == 0 || string.IsNullOrEmpty(saAbbrevEraNames[0]))
334 {
336 }
337 break;
338 default:
340 break;
341 }
342 }
343
344 internal static int GetCalendarCurrentEra(Calendar calendar)
345 {
347 {
348 return Invariant.iCurrentEra;
349 }
352 return CultureInfo.GetCultureInfo(name)._cultureData.GetCalendar(baseCalendarID).iCurrentEra;
353 }
354
356 {
357 switch (calendarId)
358 {
359 case CalendarId.GREGORIAN_US:
360 return "fa-IR";
361 case CalendarId.JAPAN:
362 return "ja-JP";
363 case CalendarId.TAIWAN:
364 return "zh-TW";
365 case CalendarId.KOREA:
366 return "ko-KR";
367 case CalendarId.HIJRI:
368 case CalendarId.GREGORIAN_ARABIC:
369 case CalendarId.UMALQURA:
370 return "ar-SA";
371 case CalendarId.THAI:
372 return "th-TH";
373 case CalendarId.HEBREW:
374 return "he-IL";
375 case CalendarId.GREGORIAN_ME_FRENCH:
376 return "ar-DZ";
377 case CalendarId.GREGORIAN_XLIT_ENGLISH:
378 case CalendarId.GREGORIAN_XLIT_FRENCH:
379 return "ar-IQ";
380 default:
381 return "en-US";
382 }
383 }
384
386 {
388 {
390 }
392 }
393
395 {
396 bool flag = true;
399 if (sMonthDay != null)
400 {
402 }
409 string leapHebrewMonthName = null;
411 if (leapHebrewMonthName != null)
412 {
413 saLeapYearMonthNames = (string[])saMonthNames.Clone();
417 }
423 }
424
426 {
427 return -1;
428 }
429
430 internal static int IcuGetCalendars(string localeName, CalendarId[] calendars)
431 {
432 int num = Interop.Globalization.GetCalendars(localeName, calendars, calendars.Length);
433 if (num == 0 && calendars.Length != 0)
434 {
435 calendars[0] = CalendarId.GREGORIAN;
436 num = 1;
437 }
438 return num;
439 }
440
442 {
443 return true;
444 }
445
446 private unsafe static bool GetCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType dataType, out string calendarString)
447 {
448 return Interop.CallStringMethod(delegate(Span<char> buffer, string locale, CalendarId id, CalendarDataType type)
449 {
450 fixed (char* result = buffer)
451 {
452 return Interop.Globalization.GetCalendarInfo(locale, id, type, result, buffer.Length);
453 }
454 }, localeName, calendarId, dataType, out calendarString);
455 }
456
457 private static bool EnumDatePatterns(string localeName, CalendarId calendarId, CalendarDataType dataType, out string[] datePatterns)
458 {
459 datePatterns = null;
461 callbackContext.Results = new List<string>();
462 callbackContext.DisallowDuplicates = true;
464 if (flag)
465 {
467 for (int i = 0; i < results.Count; i++)
468 {
470 }
471 if (dataType == CalendarDataType.ShortDates)
472 {
474 }
475 datePatterns = results.ToArray();
476 }
477 return flag;
478 }
479
481 {
482 if (shortDatePatterns.Count == 0)
483 {
484 return;
485 }
486 string text = shortDatePatterns[0];
487 if (text.Length > 100)
488 {
489 return;
490 }
491 Span<char> span = stackalloc char[text.Length + 2];
492 int i;
493 for (i = 0; i < text.Length; i++)
494 {
495 if (text[i] == '\'')
496 {
497 do
498 {
499 span[i] = text[i];
500 i++;
501 }
502 while (i < text.Length && text[i] != '\'');
503 if (i >= text.Length)
504 {
505 return;
506 }
507 }
508 else if (text[i] == 'y')
509 {
510 span[i] = 'y';
511 break;
512 }
513 span[i] = text[i];
514 }
515 if (i >= text.Length - 1 || text[i + 1] != 'y' || (i + 2 < text.Length && text[i + 2] == 'y'))
516 {
517 return;
518 }
519 span[i + 1] = 'y';
520 span[i + 2] = 'y';
521 span[i + 3] = 'y';
522 for (i += 2; i < text.Length; i++)
523 {
524 span[i + 2] = text[i];
525 }
526 shortDatePatterns[0] = span.ToString();
527 for (int j = 1; j < shortDatePatterns.Count; j++)
528 {
530 {
532 return;
533 }
534 }
536 }
537
538 private static string NormalizeDatePattern(string input)
539 {
541 int index = 0;
542 while (index < input.Length)
543 {
544 switch (input[index])
545 {
546 case '\'':
547 stringBuilder.Append(input[index++]);
548 while (index < input.Length)
549 {
550 char c = input[index++];
551 stringBuilder.Append(c);
552 if (c == '\'')
553 {
554 break;
555 }
556 }
557 break;
558 case 'E':
559 case 'c':
560 case 'e':
562 break;
563 case 'L':
564 case 'M':
565 {
567 if (num > 4)
568 {
569 num = 3;
570 }
571 stringBuilder.Append('M', num);
572 break;
573 }
574 case 'G':
575 {
576 int num = CountOccurrences(input, 'G', ref index);
577 stringBuilder.Append('g');
578 break;
579 }
580 case 'y':
581 {
582 int num = CountOccurrences(input, 'y', ref index);
583 if (num == 1)
584 {
585 num = 4;
586 }
587 stringBuilder.Append('y', num);
588 break;
589 }
590 default:
591 stringBuilder.Append(input[index++]);
592 break;
593 }
594 }
596 }
597
598 private static void NormalizeDayOfWeek(string input, StringBuilder destination, ref int index)
599 {
600 char value = input[index];
601 int val = CountOccurrences(input, value, ref index);
602 val = Math.Max(val, 3);
603 if (val > 4)
604 {
605 val = 3;
606 }
607 destination.Append('d', val);
608 }
609
610 private static int CountOccurrences(string input, char value, ref int index)
611 {
612 int num = index;
613 while (index < input.Length && input[index] == value)
614 {
615 index++;
616 }
617 return index - num;
618 }
619
620 private static bool EnumMonthNames(string localeName, CalendarId calendarId, CalendarDataType dataType, out string[] monthNames, ref string leapHebrewMonthName)
621 {
622 monthNames = null;
624 callbackContext.Results = new List<string>();
626 if (flag)
627 {
628 if (callbackContext.Results.Count == 12)
629 {
630 callbackContext.Results.Add(string.Empty);
631 }
632 if (callbackContext.Results.Count > 13)
633 {
634 if (calendarId == CalendarId.HEBREW)
635 {
637 }
638 callbackContext.Results.RemoveRange(13, callbackContext.Results.Count - 13);
639 }
640 monthNames = callbackContext.Results.ToArray();
641 }
642 return flag;
643 }
644
645 private static bool EnumEraNames(string localeName, CalendarId calendarId, CalendarDataType dataType, out string[] eraNames)
646 {
647 bool result = EnumCalendarInfo(localeName, calendarId, dataType, out eraNames);
648 if (calendarId != CalendarId.JAPAN && calendarId != CalendarId.JAPANESELUNISOLAR)
649 {
650 string[] obj = eraNames;
651 if (obj != null && obj.Length != 0)
652 {
653 string[] array = new string[1] { eraNames[eraNames.Length - 1] };
654 eraNames = array;
655 }
656 }
657 return result;
658 }
659
660 internal static bool EnumCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType dataType, out string[] calendarData)
661 {
662 calendarData = null;
664 callbackContext.Results = new List<string>();
666 if (flag)
667 {
668 calendarData = callbackContext.Results.ToArray();
669 }
670 return flag;
671 }
672
677
679 private unsafe static void EnumCalendarInfoCallback(char* calendarStringPtr, IntPtr context)
680 {
681 try
682 {
684 ref IcuEnumCalendarsData reference = ref Unsafe.As<byte, IcuEnumCalendarsData>(ref *(byte*)(void*)context);
685 if (reference.DisallowDuplicates)
686 {
687 foreach (string result in reference.Results)
688 {
689 if (string.CompareOrdinal(strA, result) == 0)
690 {
691 return;
692 }
693 }
694 }
695 reference.Results.Add(strA.ToString());
696 }
697 catch (Exception)
698 {
699 }
700 }
701
703 {
705 {
706 if (!CallGetCalendarInfoEx((string)null, calendarId, 48u, out int data))
707 {
708 return -1;
709 }
710 return data;
711 }
712 return Invariant.iTwoDigitYearMax;
713 }
714
716 {
717 string data;
718 return CallGetCalendarInfoEx("zh-TW", CalendarId.TAIWAN, 2u, out data);
719 }
720
721 private static bool CallGetCalendarInfoEx(string localeName, CalendarId calendar, uint calType, out int data)
722 {
723 return Interop.Kernel32.GetCalendarInfoEx(localeName, (uint)calendar, IntPtr.Zero, calType | 0x20000000u, IntPtr.Zero, 0, out data) != 0;
724 }
725
726 private unsafe static bool CallGetCalendarInfoEx(string localeName, CalendarId calendar, uint calType, out string data)
727 {
728 char* ptr = stackalloc char[80];
729 int num = Interop.Kernel32.GetCalendarInfoEx(localeName, (uint)calendar, IntPtr.Zero, calType, (IntPtr)ptr, 80, IntPtr.Zero);
730 if (num > 0)
731 {
732 if (ptr[num - 1] == '\0')
733 {
734 num--;
735 }
736 data = new string(ptr, 0, num);
737 return true;
738 }
739 data = "";
740 return false;
741 }
742
744 private unsafe static Interop.BOOL EnumCalendarInfoCallback(char* lpCalendarInfoString, uint calendar, IntPtr pReserved, void* lParam)
745 {
746 ref EnumData reference = ref Unsafe.As<byte, EnumData>(ref *(byte*)lParam);
747 try
748 {
749 string text = new string(lpCalendarInfoString);
750 if (reference.userOverride != text)
751 {
752 reference.strings.Add(text);
753 }
754 return Interop.BOOL.TRUE;
755 }
756 catch (Exception)
757 {
758 return Interop.BOOL.FALSE;
759 }
760 }
761
763 private unsafe static Interop.BOOL EnumCalendarsCallback(char* lpCalendarInfoString, uint calendar, IntPtr reserved, void* lParam)
764 {
766 try
767 {
768 if (reference.userOverride != calendar)
769 {
770 reference.calendars.Add((int)calendar);
771 }
772 return Interop.BOOL.TRUE;
773 }
774 catch (Exception)
775 {
776 return Interop.BOOL.FALSE;
777 }
778 }
779
802
803 private void InsertOrSwapOverride(string value, ref string[] destination)
804 {
805 if (value == null)
806 {
807 return;
808 }
809 for (int i = 0; i < destination.Length; i++)
810 {
811 if (destination[i] == value)
812 {
813 if (i > 0)
814 {
815 string text = destination[0];
816 destination[0] = value;
817 destination[i] = text;
818 }
819 return;
820 }
821 }
822 string[] array = new string[destination.Length + 1];
823 array[0] = value;
824 Array.Copy(destination, 0, array, 1, destination.Length);
826 }
827
829 {
830 bool flag = true;
831 uint num = ((!bUseUserOverrides) ? 2147483648u : 0u);
844 if (calendarId == CalendarId.GREGORIAN)
845 {
848 }
855 return flag;
856 }
857
859 {
860 switch (calendarId)
861 {
862 case CalendarId.JAPANESELUNISOLAR:
863 calendarId = CalendarId.JAPAN;
864 break;
865 case CalendarId.JULIAN:
866 case CalendarId.CHINESELUNISOLAR:
867 case CalendarId.SAKA:
868 case CalendarId.LUNAR_ETO_CHN:
869 case CalendarId.LUNAR_ETO_KOR:
870 case CalendarId.LUNAR_ETO_ROKUYOU:
871 case CalendarId.KOREANLUNISOLAR:
872 case CalendarId.TAIWANLUNISOLAR:
873 calendarId = CalendarId.GREGORIAN_US;
874 break;
875 }
877 }
878
879 private static void CheckSpecialCalendar(ref CalendarId calendar, ref string localeName)
880 {
881 switch (calendar)
882 {
883 case CalendarId.GREGORIAN_US:
884 {
885 if (!CallGetCalendarInfoEx(localeName, calendar, 2u, out string data))
886 {
887 localeName = "fa-IR";
888 if (!CallGetCalendarInfoEx(localeName, calendar, 2u, out data))
889 {
890 localeName = "en-US";
891 calendar = CalendarId.GREGORIAN;
892 }
893 }
894 break;
895 }
896 case CalendarId.TAIWAN:
898 {
899 calendar = CalendarId.GREGORIAN;
900 }
901 break;
902 }
903 }
904
905 private unsafe static bool CallEnumCalendarInfo(string localeName, CalendarId calendar, uint calType, uint lcType, out string[] data)
906 {
907 EnumData value = default(EnumData);
908 value.userOverride = null;
909 value.strings = new List<string>();
910 if (lcType != 0 && (lcType & 0x80000000u) == 0)
911 {
913 if (calendarId == calendar)
914 {
916 if (localeInfoEx != null)
917 {
918 value.userOverride = localeInfoEx;
919 value.strings.Add(localeInfoEx);
920 }
921 }
922 }
924 if (value.strings.Count == 0)
925 {
926 data = null;
927 return false;
928 }
929 string[] array = value.strings.ToArray();
930 if (calType == 57 || calType == 4)
931 {
932 Array.Reverse(array, 0, array.Length);
933 }
934 data = array;
935 return true;
936 }
937
938 private static bool GetCalendarDayInfo(string localeName, CalendarId calendar, uint calType, out string[] outputStrings)
939 {
940 bool flag = true;
941 string[] array = new string[7];
942 int num = 0;
943 while (num < 7)
944 {
945 flag &= CallGetCalendarInfoEx(localeName, calendar, calType, out array[num]);
946 if (num == 0)
947 {
948 calType -= 7;
949 }
950 num++;
951 calType++;
952 }
954 return flag;
955 }
956
957 private static bool GetCalendarMonthInfo(string localeName, CalendarId calendar, uint calType, out string[] outputStrings)
958 {
959 string[] array = new string[13];
960 int num = 0;
961 while (num < 13)
962 {
963 if (!CallGetCalendarInfoEx(localeName, calendar, calType, out array[num]))
964 {
965 array[num] = "";
966 }
967 num++;
968 calType++;
969 }
971 return true;
972 }
973
974 internal static int GetCalendarsCore(string localeName, bool useUserOverride, CalendarId[] calendars)
975 {
977 {
978 return NlsGetCalendars(localeName, useUserOverride, calendars);
979 }
980 int num = IcuGetCalendars(localeName, calendars);
981 if (useUserOverride)
982 {
984 if (localeInfoExInt != 0 && (uint)(ushort)localeInfoExInt != (uint)calendars[0])
985 {
987 for (int i = 1; i < calendars.Length; i++)
988 {
989 if (calendars[i] == calendarId)
990 {
991 CalendarId calendarId2 = calendars[0];
992 calendars[0] = calendarId;
993 calendars[i] = calendarId2;
994 return num;
995 }
996 }
997 num = ((num < calendars.Length) ? (num + 1) : num);
999 span[0] = calendarId;
1000 calendars.AsSpan(0, num - 1).CopyTo(span.Slice(1));
1001 span.CopyTo(calendars);
1002 }
1003 }
1004 return num;
1005 }
1006
1007 private unsafe static int NlsGetCalendars(string localeName, bool useUserOverride, CalendarId[] calendars)
1008 {
1010 value.userOverride = 0;
1011 value.calendars = new List<int>();
1012 if (useUserOverride)
1013 {
1015 if (localeInfoExInt != 0)
1016 {
1017 value.userOverride = localeInfoExInt;
1018 value.calendars.Add(localeInfoExInt);
1019 }
1020 }
1022 for (int i = 0; i < Math.Min(calendars.Length, value.calendars.Count); i++)
1023 {
1024 calendars[i] = (CalendarId)value.calendars[i];
1025 }
1026 return value.calendars.Count;
1027 }
1028}
static unsafe ResultCode GetCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType calendarDataType, char *result, int resultCapacity)
static int GetCalendars(string localeName, CalendarId[] calendars, int calendarsCapacity)
static unsafe bool EnumCalendarInfo(delegate *unmanaged< char *, IntPtr, void > callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context)
static int GetCalendarInfoEx(string lpLocaleName, uint Calendar, IntPtr lpReserved, uint CalType, IntPtr lpCalData, int cchData, out int lpValue)
static unsafe bool EnumCalendarInfoExEx(delegate *unmanaged< char *, uint, IntPtr, void *, BOOL > pCalInfoEnumProcExEx, string lpLocaleName, uint Calendar, string lpReserved, uint CalType, void *lParam)
static void Reverse(Array array)
Definition Array.cs:2207
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
void Add(TKey key, TValue value)
static unsafe void EnumCalendarInfoCallback(char *calendarStringPtr, IntPtr context)
static unsafe bool GetCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType dataType, out string calendarString)
static int IcuGetCalendars(string localeName, CalendarId[] calendars)
void InsertOrSwapOverride(string value, ref string[] destination)
static bool CallGetCalendarInfoEx(string localeName, CalendarId calendar, uint calType, out int data)
void InitializeAbbreviatedEraNames(string localeName, CalendarId calendarId)
static void CheckSpecialCalendar(ref CalendarId calendar, ref string localeName)
static unsafe Interop.BOOL EnumCalendarInfoCallback(char *lpCalendarInfoString, uint calendar, IntPtr pReserved, void *lParam)
static void NormalizeCalendarId(ref CalendarId calendarId, ref string localeName)
static int GetCalendarCurrentEra(Calendar calendar)
static int CountOccurrences(string input, char value, ref int index)
static string CalendarIdToCultureName(CalendarId calendarId)
static string NormalizeDatePattern(string input)
static int GetCalendarsCore(string localeName, bool useUserOverride, CalendarId[] calendars)
bool IcuLoadCalendarDataFromSystem(string localeName, CalendarId calendarId)
static unsafe int NlsGetCalendars(string localeName, bool useUserOverride, CalendarId[] calendars)
static int IcuGetTwoDigitYearMax(CalendarId calendarId)
static bool EnumDatePatterns(string localeName, CalendarId calendarId, CalendarDataType dataType, out string[] datePatterns)
static void FixDefaultShortDatePattern(List< string > shortDatePatterns)
static int NlsGetTwoDigitYearMax(CalendarId calendarId)
static bool EnumEraNames(string localeName, CalendarId calendarId, CalendarDataType dataType, out string[] eraNames)
bool NlsLoadCalendarDataFromSystem(string localeName, CalendarId calendarId)
static bool NlsSystemSupportsTaiwaneseCalendar()
void InitializeEraNames(string localeName, CalendarId calendarId)
static bool GetCalendarDayInfo(string localeName, CalendarId calendar, uint calType, out string[] outputStrings)
static readonly CalendarData Invariant
static unsafe bool CallGetCalendarInfoEx(string localeName, CalendarId calendar, uint calType, out string data)
bool LoadCalendarDataFromSystemCore(string localeName, CalendarId calendarId)
static bool EnumMonthNames(string localeName, CalendarId calendarId, CalendarDataType dataType, out string[] monthNames, ref string leapHebrewMonthName)
static bool EnumCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType dataType, out string[] calendarData)
static CalendarData CreateInvariant()
static bool SystemSupportsTaiwaneseCalendar()
static unsafe bool CallEnumCalendarInfo(string localeName, CalendarId calendar, uint calType, uint lcType, out string[] data)
static void NormalizeDayOfWeek(string input, StringBuilder destination, ref int index)
static unsafe Interop.BOOL EnumCalendarsCallback(char *lpCalendarInfoString, uint calendar, IntPtr reserved, void *lParam)
CalendarData(string localeName, CalendarId calendarId, bool bUseUserOverrides)
static unsafe bool EnumCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType dataType, ref IcuEnumCalendarsData callbackContext)
static bool GetCalendarMonthInfo(string localeName, CalendarId calendar, uint calType, out string[] outputStrings)
static bool IcuSystemSupportsTaiwaneseCalendar()
virtual CalendarId BaseCalendarID
Definition Calendar.cs:21
static string[] ReescapeWin32Strings(string[] array)
static unsafe string GetLocaleInfoEx(string localeName, uint field)
static unsafe int GetLocaleInfoExInt(string localeName, uint field)
static string ReescapeWin32String(string str)
static CultureInfo GetCultureInfo(int culture)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static unsafe ReadOnlySpan< char > CreateReadOnlySpanFromNullTerminated(char *value)
static string GetStringAndRelease(StringBuilder sb)
static StringBuilder Acquire(int capacity=16)
static readonly IntPtr Zero
Definition IntPtr.cs:18