// Token: 0x060015E2 RID: 5602 RVA: 0x000405A4 File Offset: 0x0003E7A4 private static string FormatHebrewMonthName(DateTime time, int month, int repeatCount, DateTimeFormatInfo dtfi) { if (dtfi.Calendar.IsLeapYear(dtfi.Calendar.GetYear(time))) { return(dtfi.internalGetMonthName(month, MonthNameStyles.LeapYear, repeatCount == 3)); } if (month >= 7) { month++; } if (repeatCount == 3) { return(dtfi.GetAbbreviatedMonthName(month)); } return(dtfi.GetMonthName(month)); }
// // FormatHebrewMonthName // // Action: Return the Hebrew month name for the specified DateTime. // Returns: The month name string for the specified DateTime. // Arguments: // time the time to format // month The month is the value of HebrewCalendar.GetMonth(time). // repeat Return abbreviated month name if repeat=3, or full month name if repeat=4 // dtfi The DateTimeFormatInfo which uses the Hebrew calendars as its calendar. // Exceptions: None. // /* Note: * If DTFI is using Hebrew calendar, GetMonthName()/GetAbbreviatedMonthName() will return month names like this: * 1 Hebrew 1st Month * 2 Hebrew 2nd Month * .. ... * 6 Hebrew 6th Month * 7 Hebrew 6th Month II (used only in a leap year) * 8 Hebrew 7th Month * 9 Hebrew 8th Month * 10 Hebrew 9th Month * 11 Hebrew 10th Month * 12 Hebrew 11th Month * 13 Hebrew 12th Month * * Therefore, if we are in a regular year, we have to increment the month name if moth is greater or eqaul to 7. */ private static String FormatHebrewMonthName(DateTime time, int month, int repeatCount, DateTimeFormatInfo dtfi) { Contract.Assert(repeatCount != 3 || repeatCount != 4, "repeateCount should be 3 or 4"); if (dtfi.Calendar.IsLeapYear(dtfi.Calendar.GetYear(time))) { // This month is in a leap year return(dtfi.internalGetMonthName(month, MonthNameStyles.LeapYear, (repeatCount == 3))); } // This is in a regular year. if (month >= 7) { month++; } if (repeatCount == 3) { return(dtfi.GetAbbreviatedMonthName(month)); } return(dtfi.GetMonthName(month)); }
private static string FormatCustomized(DateTime dateTime, string format, DateTimeFormatInfo dtfi, TimeSpan offset) { int num2; Calendar calendar = dtfi.Calendar; StringBuilder outputBuffer = new StringBuilder(); bool flag = calendar.ID == 8; bool timeOnly = true; for (int i = 0; i < format.Length; i += num2) { int num4; int dayOfMonth; int num8; int month; int year; char patternChar = format[i]; switch (patternChar) { case 'F': case 'f': break; case 'H': { num2 = ParseRepeatPattern(format, i, patternChar); FormatDigits(outputBuffer, dateTime.Hour, num2); continue; } case ':': { outputBuffer.Append(dtfi.TimeSeparator); num2 = 1; continue; } case '/': { outputBuffer.Append(dtfi.DateSeparator); num2 = 1; continue; } case '%': { num4 = ParseNextChar(format, i); if ((num4 < 0) || (num4 == 0x25)) { throw new FormatException(Environment.GetResourceString("Format_InvalidString")); } char ch3 = (char)num4; outputBuffer.Append(FormatCustomized(dateTime, ch3.ToString(), dtfi, offset)); num2 = 2; continue; } case '\'': case '"': { StringBuilder result = new StringBuilder(); num2 = ParseQuoteString(format, i, result); outputBuffer.Append(result); continue; } case 'K': { num2 = 1; FormatCustomizedRoundripTimeZone(dateTime, offset, outputBuffer); continue; } case 'M': num2 = ParseRepeatPattern(format, i, patternChar); month = calendar.GetMonth(dateTime); if (num2 > 2) { goto Label_03D3; } if (!flag) { goto Label_03C7; } HebrewFormatDigits(outputBuffer, month); goto Label_042E; case '\\': { num4 = ParseNextChar(format, i); if (num4 < 0) { throw new FormatException(Environment.GetResourceString("Format_InvalidString")); } outputBuffer.Append((char)num4); num2 = 2; continue; } case 'd': num2 = ParseRepeatPattern(format, i, patternChar); if (num2 > 2) { goto Label_037F; } dayOfMonth = calendar.GetDayOfMonth(dateTime); if (!flag) { goto Label_0373; } HebrewFormatDigits(outputBuffer, dayOfMonth); goto Label_0399; case 'g': { num2 = ParseRepeatPattern(format, i, patternChar); outputBuffer.Append(dtfi.GetEraName(calendar.GetEra(dateTime))); continue; } case 'h': { num2 = ParseRepeatPattern(format, i, patternChar); int num3 = dateTime.Hour % 12; if (num3 == 0) { num3 = 12; } FormatDigits(outputBuffer, num3, num2); continue; } case 's': { num2 = ParseRepeatPattern(format, i, patternChar); FormatDigits(outputBuffer, dateTime.Second, num2); continue; } case 't': { num2 = ParseRepeatPattern(format, i, patternChar); if (num2 != 1) { goto Label_0327; } if (dateTime.Hour >= 12) { goto Label_02FE; } if (dtfi.AMDesignator.Length >= 1) { outputBuffer.Append(dtfi.AMDesignator[0]); } continue; } case 'm': { num2 = ParseRepeatPattern(format, i, patternChar); FormatDigits(outputBuffer, dateTime.Minute, num2); continue; } case 'y': year = calendar.GetYear(dateTime); num2 = ParseRepeatPattern(format, i, patternChar); if (!dtfi.HasForceTwoDigitYears) { goto Label_0466; } FormatDigits(outputBuffer, year, (num2 <= 2) ? num2 : 2); goto Label_04B5; case 'z': { num2 = ParseRepeatPattern(format, i, patternChar); FormatCustomizedTimeZone(dateTime, offset, format, num2, timeOnly, outputBuffer); continue; } default: goto Label_05A4; } num2 = ParseRepeatPattern(format, i, patternChar); if (num2 > 7) { throw new FormatException(Environment.GetResourceString("Format_InvalidString")); } long num5 = dateTime.Ticks % 0x989680L; num5 /= (long)Math.Pow(10.0, (double)(7 - num2)); if (patternChar == 'f') { outputBuffer.Append(((int)num5).ToString(fixedNumberFormats[num2 - 1], CultureInfo.InvariantCulture)); continue; } int num6 = num2; while (num6 > 0) { if ((num5 % 10L) != 0L) { break; } num5 /= 10L; num6--; } if (num6 > 0) { outputBuffer.Append(((int)num5).ToString(fixedNumberFormats[num6 - 1], CultureInfo.InvariantCulture)); } else if ((outputBuffer.Length > 0) && (outputBuffer[outputBuffer.Length - 1] == '.')) { outputBuffer.Remove(outputBuffer.Length - 1, 1); } continue; Label_02FE: if (dtfi.PMDesignator.Length >= 1) { outputBuffer.Append(dtfi.PMDesignator[0]); } continue; Label_0327: outputBuffer.Append((dateTime.Hour < 12) ? dtfi.AMDesignator : dtfi.PMDesignator); continue; Label_0373: FormatDigits(outputBuffer, dayOfMonth, num2); goto Label_0399; Label_037F: num8 = (int)calendar.GetDayOfWeek(dateTime); outputBuffer.Append(FormatDayOfWeek(num8, num2, dtfi)); Label_0399: timeOnly = false; continue; Label_03C7: FormatDigits(outputBuffer, month, num2); goto Label_042E; Label_03D3: if (flag) { outputBuffer.Append(FormatHebrewMonthName(dateTime, month, num2, dtfi)); } else if (((dtfi.FormatFlags & DateTimeFormatFlags.UseGenitiveMonth) != DateTimeFormatFlags.None) && (num2 >= 4)) { outputBuffer.Append(dtfi.internalGetMonthName(month, IsUseGenitiveForm(format, i, num2, 'd') ? MonthNameStyles.Genitive : MonthNameStyles.Regular, false)); } else { outputBuffer.Append(FormatMonth(month, num2, dtfi)); } Label_042E: timeOnly = false; continue; Label_0466: if (calendar.ID == 8) { HebrewFormatDigits(outputBuffer, year); } else if (num2 <= 2) { FormatDigits(outputBuffer, year % 100, num2); } else { string str = "D" + num2; outputBuffer.Append(year.ToString(str, CultureInfo.InvariantCulture)); } Label_04B5: timeOnly = false; continue; Label_05A4: outputBuffer.Append(patternChar); num2 = 1; } return(outputBuffer.ToString()); }
// Token: 0x060015E6 RID: 5606 RVA: 0x00040744 File Offset: 0x0003E944 private static string FormatCustomized(DateTime dateTime, string format, DateTimeFormatInfo dtfi, TimeSpan offset) { Calendar calendar = dtfi.Calendar; StringBuilder stringBuilder = StringBuilderCache.Acquire(16); bool flag = calendar.ID == 8; bool flag2 = calendar.ID == 3; bool timeOnly = true; int i = 0; while (i < format.Length) { char c = format[i]; int num2; if (c <= 'K') { if (c <= '/') { if (c <= '%') { if (c != '"') { if (c != '%') { goto IL_64F; } int num = DateTimeFormat.ParseNextChar(format, i); if (num >= 0 && num != 37) { stringBuilder.Append(DateTimeFormat.FormatCustomized(dateTime, ((char)num).ToString(), dtfi, offset)); num2 = 2; goto IL_65B; } throw new FormatException(Environment.GetResourceString("Format_InvalidString")); } } else if (c != '\'') { if (c != '/') { goto IL_64F; } stringBuilder.Append(dtfi.DateSeparator); num2 = 1; goto IL_65B; } StringBuilder stringBuilder2 = new StringBuilder(); num2 = DateTimeFormat.ParseQuoteString(format, i, stringBuilder2); stringBuilder.Append(stringBuilder2); } else if (c <= 'F') { if (c != ':') { if (c != 'F') { goto IL_64F; } goto IL_1E3; } else { stringBuilder.Append(dtfi.TimeSeparator); num2 = 1; } } else if (c != 'H') { if (c != 'K') { goto IL_64F; } num2 = 1; DateTimeFormat.FormatCustomizedRoundripTimeZone(dateTime, offset, stringBuilder); } else { num2 = DateTimeFormat.ParseRepeatPattern(format, i, c); DateTimeFormat.FormatDigits(stringBuilder, dateTime.Hour, num2); } } else if (c <= 'm') { if (c <= '\\') { if (c != 'M') { if (c != '\\') { goto IL_64F; } int num = DateTimeFormat.ParseNextChar(format, i); if (num < 0) { throw new FormatException(Environment.GetResourceString("Format_InvalidString")); } stringBuilder.Append((char)num); num2 = 2; } else { num2 = DateTimeFormat.ParseRepeatPattern(format, i, c); int month = calendar.GetMonth(dateTime); if (num2 <= 2) { if (flag) { DateTimeFormat.HebrewFormatDigits(stringBuilder, month); } else { DateTimeFormat.FormatDigits(stringBuilder, month, num2); } } else if (flag) { stringBuilder.Append(DateTimeFormat.FormatHebrewMonthName(dateTime, month, num2, dtfi)); } else if ((dtfi.FormatFlags & DateTimeFormatFlags.UseGenitiveMonth) != DateTimeFormatFlags.None && num2 >= 4) { stringBuilder.Append(dtfi.internalGetMonthName(month, DateTimeFormat.IsUseGenitiveForm(format, i, num2, 'd') ? MonthNameStyles.Genitive : MonthNameStyles.Regular, false)); } else { stringBuilder.Append(DateTimeFormat.FormatMonth(month, num2, dtfi)); } timeOnly = false; } } else { switch (c) { case 'd': num2 = DateTimeFormat.ParseRepeatPattern(format, i, c); if (num2 <= 2) { int dayOfMonth = calendar.GetDayOfMonth(dateTime); if (flag) { DateTimeFormat.HebrewFormatDigits(stringBuilder, dayOfMonth); } else { DateTimeFormat.FormatDigits(stringBuilder, dayOfMonth, num2); } } else { int dayOfWeek = (int)calendar.GetDayOfWeek(dateTime); stringBuilder.Append(DateTimeFormat.FormatDayOfWeek(dayOfWeek, num2, dtfi)); } timeOnly = false; break; case 'e': goto IL_64F; case 'f': goto IL_1E3; case 'g': num2 = DateTimeFormat.ParseRepeatPattern(format, i, c); stringBuilder.Append(dtfi.GetEraName(calendar.GetEra(dateTime))); break; case 'h': { num2 = DateTimeFormat.ParseRepeatPattern(format, i, c); int num3 = dateTime.Hour % 12; if (num3 == 0) { num3 = 12; } DateTimeFormat.FormatDigits(stringBuilder, num3, num2); break; } default: if (c != 'm') { goto IL_64F; } num2 = DateTimeFormat.ParseRepeatPattern(format, i, c); DateTimeFormat.FormatDigits(stringBuilder, dateTime.Minute, num2); break; } } } else if (c <= 't') { if (c != 's') { if (c != 't') { goto IL_64F; } num2 = DateTimeFormat.ParseRepeatPattern(format, i, c); if (num2 == 1) { if (dateTime.Hour < 12) { if (dtfi.AMDesignator.Length >= 1) { stringBuilder.Append(dtfi.AMDesignator[0]); } } else if (dtfi.PMDesignator.Length >= 1) { stringBuilder.Append(dtfi.PMDesignator[0]); } } else { stringBuilder.Append((dateTime.Hour < 12) ? dtfi.AMDesignator : dtfi.PMDesignator); } } else { num2 = DateTimeFormat.ParseRepeatPattern(format, i, c); DateTimeFormat.FormatDigits(stringBuilder, dateTime.Second, num2); } } else if (c != 'y') { if (c != 'z') { goto IL_64F; } num2 = DateTimeFormat.ParseRepeatPattern(format, i, c); DateTimeFormat.FormatCustomizedTimeZone(dateTime, offset, format, num2, timeOnly, stringBuilder); } else { int year = calendar.GetYear(dateTime); num2 = DateTimeFormat.ParseRepeatPattern(format, i, c); if (flag2 && !AppContextSwitches.FormatJapaneseFirstYearAsANumber && year == 1 && ((i + num2 < format.Length && format[i + num2] == "年"[0]) || (i + num2 < format.Length - 1 && format[i + num2] == '\'' && format[i + num2 + 1] == "年"[0]))) { stringBuilder.Append("元"[0]); } else if (dtfi.HasForceTwoDigitYears) { DateTimeFormat.FormatDigits(stringBuilder, year, (num2 <= 2) ? num2 : 2); } else if (calendar.ID == 8) { DateTimeFormat.HebrewFormatDigits(stringBuilder, year); } else if (num2 <= 2) { DateTimeFormat.FormatDigits(stringBuilder, year % 100, num2); } else { string format2 = "D" + num2; stringBuilder.Append(year.ToString(format2, CultureInfo.InvariantCulture)); } timeOnly = false; } IL_65B: i += num2; continue; IL_1E3: num2 = DateTimeFormat.ParseRepeatPattern(format, i, c); if (num2 > 7) { throw new FormatException(Environment.GetResourceString("Format_InvalidString")); } long num4 = dateTime.Ticks % 10000000L; num4 /= (long)Math.Pow(10.0, (double)(7 - num2)); if (c == 'f') { stringBuilder.Append(((int)num4).ToString(DateTimeFormat.fixedNumberFormats[num2 - 1], CultureInfo.InvariantCulture)); goto IL_65B; } int num5 = num2; while (num5 > 0 && num4 % 10L == 0L) { num4 /= 10L; num5--; } if (num5 > 0) { stringBuilder.Append(((int)num4).ToString(DateTimeFormat.fixedNumberFormats[num5 - 1], CultureInfo.InvariantCulture)); goto IL_65B; } if (stringBuilder.Length > 0 && stringBuilder[stringBuilder.Length - 1] == '.') { stringBuilder.Remove(stringBuilder.Length - 1, 1); goto IL_65B; } goto IL_65B; IL_64F: stringBuilder.Append(c); num2 = 1; goto IL_65B; } return(StringBuilderCache.GetStringAndRelease(stringBuilder)); }
private static string FormatCustomized(DateTime dateTime, string format, DateTimeFormatInfo dtfi, TimeSpan offset) { Calendar calendar = dtfi.Calendar; StringBuilder stringBuilder1 = StringBuilderCache.Acquire(16); bool flag = calendar.ID == 8; bool timeOnly = true; int index1 = 0; while (index1 < format.Length) { char patternChar = format[index1]; int num1; if ((uint)patternChar <= 75U) { if ((uint)patternChar <= 47U) { if ((uint)patternChar <= 37U) { if ((int)patternChar != 34) { if ((int)patternChar == 37) { int nextChar = DateTimeFormat.ParseNextChar(format, index1); if (nextChar < 0 || nextChar == 37) { throw new FormatException(Environment.GetResourceString("Format_InvalidString")); } stringBuilder1.Append(DateTimeFormat.FormatCustomized(dateTime, ((char)nextChar).ToString(), dtfi, offset)); num1 = 2; goto label_85; } else { goto label_84; } } } else if ((int)patternChar != 39) { if ((int)patternChar == 47) { stringBuilder1.Append(dtfi.DateSeparator); num1 = 1; goto label_85; } else { goto label_84; } } StringBuilder result = new StringBuilder(); num1 = DateTimeFormat.ParseQuoteString(format, index1, result); stringBuilder1.Append((object)result); goto label_85; } else if ((uint)patternChar <= 70U) { if ((int)patternChar != 58) { if ((int)patternChar != 70) { goto label_84; } } else { stringBuilder1.Append(dtfi.TimeSeparator); num1 = 1; goto label_85; } } else if ((int)patternChar != 72) { if ((int)patternChar == 75) { num1 = 1; DateTimeFormat.FormatCustomizedRoundripTimeZone(dateTime, offset, stringBuilder1); goto label_85; } else { goto label_84; } } else { num1 = DateTimeFormat.ParseRepeatPattern(format, index1, patternChar); DateTimeFormat.FormatDigits(stringBuilder1, dateTime.Hour, num1); goto label_85; } } else if ((uint)patternChar <= 109U) { if ((uint)patternChar <= 92U) { if ((int)patternChar != 77) { if ((int)patternChar == 92) { int nextChar = DateTimeFormat.ParseNextChar(format, index1); if (nextChar < 0) { throw new FormatException(Environment.GetResourceString("Format_InvalidString")); } stringBuilder1.Append((char)nextChar); num1 = 2; goto label_85; } else { goto label_84; } } else { num1 = DateTimeFormat.ParseRepeatPattern(format, index1, patternChar); int month = calendar.GetMonth(dateTime); if (num1 <= 2) { if (flag) { DateTimeFormat.HebrewFormatDigits(stringBuilder1, month); } else { DateTimeFormat.FormatDigits(stringBuilder1, month, num1); } } else if (flag) { stringBuilder1.Append(DateTimeFormat.FormatHebrewMonthName(dateTime, month, num1, dtfi)); } else if ((dtfi.FormatFlags & DateTimeFormatFlags.UseGenitiveMonth) != DateTimeFormatFlags.None && num1 >= 4) { stringBuilder1.Append(dtfi.internalGetMonthName(month, DateTimeFormat.IsUseGenitiveForm(format, index1, num1, 'd') ? MonthNameStyles.Genitive : MonthNameStyles.Regular, false)); } else { stringBuilder1.Append(DateTimeFormat.FormatMonth(month, num1, dtfi)); } timeOnly = false; goto label_85; } } else { switch (patternChar) { case 'd': num1 = DateTimeFormat.ParseRepeatPattern(format, index1, patternChar); if (num1 <= 2) { int dayOfMonth = calendar.GetDayOfMonth(dateTime); if (flag) { DateTimeFormat.HebrewFormatDigits(stringBuilder1, dayOfMonth); } else { DateTimeFormat.FormatDigits(stringBuilder1, dayOfMonth, num1); } } else { int dayOfWeek = (int)calendar.GetDayOfWeek(dateTime); stringBuilder1.Append(DateTimeFormat.FormatDayOfWeek(dayOfWeek, num1, dtfi)); } timeOnly = false; goto label_85; case 'f': break; case 'g': num1 = DateTimeFormat.ParseRepeatPattern(format, index1, patternChar); stringBuilder1.Append(dtfi.GetEraName(calendar.GetEra(dateTime))); goto label_85; case 'h': num1 = DateTimeFormat.ParseRepeatPattern(format, index1, patternChar); int num2 = dateTime.Hour % 12; if (num2 == 0) { num2 = 12; } DateTimeFormat.FormatDigits(stringBuilder1, num2, num1); goto label_85; case 'm': num1 = DateTimeFormat.ParseRepeatPattern(format, index1, patternChar); DateTimeFormat.FormatDigits(stringBuilder1, dateTime.Minute, num1); goto label_85; default: goto label_84; } } } else if ((uint)patternChar <= 116U) { if ((int)patternChar != 115) { if ((int)patternChar == 116) { num1 = DateTimeFormat.ParseRepeatPattern(format, index1, patternChar); if (num1 == 1) { if (dateTime.Hour < 12) { if (dtfi.AMDesignator.Length >= 1) { stringBuilder1.Append(dtfi.AMDesignator[0]); goto label_85; } else { goto label_85; } } else if (dtfi.PMDesignator.Length >= 1) { stringBuilder1.Append(dtfi.PMDesignator[0]); goto label_85; } else { goto label_85; } } else { stringBuilder1.Append(dateTime.Hour < 12 ? dtfi.AMDesignator : dtfi.PMDesignator); goto label_85; } } else { goto label_84; } } else { num1 = DateTimeFormat.ParseRepeatPattern(format, index1, patternChar); DateTimeFormat.FormatDigits(stringBuilder1, dateTime.Second, num1); goto label_85; } } else if ((int)patternChar != 121) { if ((int)patternChar == 122) { num1 = DateTimeFormat.ParseRepeatPattern(format, index1, patternChar); DateTimeFormat.FormatCustomizedTimeZone(dateTime, offset, format, num1, timeOnly, stringBuilder1); goto label_85; } else { goto label_84; } } else { int year = calendar.GetYear(dateTime); num1 = DateTimeFormat.ParseRepeatPattern(format, index1, patternChar); if (dtfi.HasForceTwoDigitYears) { DateTimeFormat.FormatDigits(stringBuilder1, year, num1 <= 2 ? num1 : 2); } else if (calendar.ID == 8) { DateTimeFormat.HebrewFormatDigits(stringBuilder1, year); } else if (num1 <= 2) { DateTimeFormat.FormatDigits(stringBuilder1, year % 100, num1); } else { string format1 = "D" + (object)num1; stringBuilder1.Append(year.ToString(format1, (IFormatProvider)CultureInfo.InvariantCulture)); } timeOnly = false; goto label_85; } num1 = DateTimeFormat.ParseRepeatPattern(format, index1, patternChar); if (num1 > 7) { throw new FormatException(Environment.GetResourceString("Format_InvalidString")); } long num3 = dateTime.Ticks % 10000000L / (long)Math.Pow(10.0, (double)(7 - num1)); if ((int)patternChar == 102) { stringBuilder1.Append(((int)num3).ToString(DateTimeFormat.fixedNumberFormats[num1 - 1], (IFormatProvider)CultureInfo.InvariantCulture)); goto label_85; } else { int num4; for (num4 = num1; num4 > 0 && num3 % 10L == 0L; --num4) { num3 /= 10L; } if (num4 > 0) { stringBuilder1.Append(((int)num3).ToString(DateTimeFormat.fixedNumberFormats[num4 - 1], (IFormatProvider)CultureInfo.InvariantCulture)); goto label_85; } else if (stringBuilder1.Length > 0) { StringBuilder stringBuilder2 = stringBuilder1; int index2 = stringBuilder2.Length - 1; if ((int)stringBuilder2[index2] == 46) { StringBuilder stringBuilder3 = stringBuilder1; int startIndex = stringBuilder3.Length - 1; int length = 1; stringBuilder3.Remove(startIndex, length); goto label_85; } else { goto label_85; } } else { goto label_85; } } label_84: stringBuilder1.Append(patternChar); num1 = 1; label_85: index1 += num1; } return(StringBuilderCache.GetStringAndRelease(stringBuilder1)); }