当前位置: 首页>>代码示例>>C#>>正文


C# DateTimeFormatInfo.internalGetMonthName方法代码示例

本文整理汇总了C#中System.Globalization.DateTimeFormatInfo.internalGetMonthName方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeFormatInfo.internalGetMonthName方法的具体用法?C# DateTimeFormatInfo.internalGetMonthName怎么用?C# DateTimeFormatInfo.internalGetMonthName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Globalization.DateTimeFormatInfo的用法示例。


在下文中一共展示了DateTimeFormatInfo.internalGetMonthName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FormatCustomized


//.........这里部分代码省略.........
                            }
                        } 
                        else
                        {
                            int dayOfWeek = (int)cal.GetDayOfWeek(dateTime);
                            result.Append(FormatDayOfWeek(dayOfWeek, tokenLen, dtfi));
                        }
                        bTimeOnly = false;
                        break;
                    case 'M':
                        // 
                        // tokenLen == 1 : Month as digits with no leading zero.
                        // tokenLen == 2 : Month as digits with leading zero for single-digit months.
                        // tokenLen == 3 : Month as a three-letter abbreviation.
                        // tokenLen >= 4 : Month as its full name.
                        //
                        tokenLen = ParseRepeatPattern(format, i, ch);
                        int month = cal.GetMonth(dateTime);
                        if (tokenLen <= 2)
                        {
                            if (isHebrewCalendar) {
                                // For Hebrew calendar, we need to convert numbers to Hebrew text for yyyy, MM, and dd values.
                                HebrewFormatDigits(result, month);
                            } else {                        
                                FormatDigits(result, month, tokenLen);
                            }
                        } 
                        else {
                            if (isHebrewCalendar) {
                                result.Append(FormatHebrewMonthName(dateTime, month, tokenLen, dtfi));
                            } else {             
                                if ((dtfi.FormatFlags & DateTimeFormatFlags.UseGenitiveMonth) != 0 && tokenLen >= 4) {
                                    result.Append(
                                        dtfi.internalGetMonthName(
                                            month, 
                                            IsUseGenitiveForm(format, i, tokenLen, 'd')? MonthNameStyles.Genitive : MonthNameStyles.Regular, 
                                            false));
                                } else {
                                result.Append(FormatMonth(month, tokenLen, dtfi));
                            }
                        }
                        }
                        bTimeOnly = false;
                        break;
                    case 'y':
                        // Notes about OS behavior:
                        // y: Always print (year % 100). No leading zero.
                        // yy: Always print (year % 100) with leading zero.
                        // yyy/yyyy/yyyyy/... : Print year value.  No leading zero.

                        int year = cal.GetYear(dateTime);
                        tokenLen = ParseRepeatPattern(format, i, ch);
                        if (dtfi.HasForceTwoDigitYears) {
                            FormatDigits(result, year, tokenLen <= 2 ? tokenLen : 2);
                        }
                        else if (cal.ID == Calendar.CAL_HEBREW) {
                            HebrewFormatDigits(result, year);
                        }
                        else {
                            if (tokenLen <= 2) {
                                FormatDigits(result, year % 100, tokenLen);
                            }
                            else {
                                String fmtPattern = "D" + tokenLen;
                                result.Append(year.ToString(fmtPattern, CultureInfo.InvariantCulture));
                            }
开发者ID:afrog33k,项目名称:csnative,代码行数:67,代码来源:DateTimeFormat.cs

示例2: GetMonthName

        //
        //  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));
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:45,代码来源:DateTimeFormat.cs

示例3: FormatHebrewMonthName

 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);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:DateTimeFormat.cs

示例4: FormatCustomized


//.........这里部分代码省略.........
                    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();
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:DateTimeFormat.cs

示例5: FormatCustomized


//.........这里部分代码省略.........
								num2 = 1;
								DateTimeFormat.FormatCustomizedRoundripTimeZone(dateTime, offset, stringBuilder);
								break;
							}
							case 'L':
							{
								goto IL_5A4;
							}
							case 'M':
							{
								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;
								break;
							}
							default:
							{
								if (c2 != '\\')
								{
									switch (c2)
									{
										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
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:67,代码来源:DateTimeFormat.cs

示例6: FormatCustomized


//.........这里部分代码省略.........
                            }
                        } 
                        else
                        {
                            int dayOfWeek = (int)cal.GetDayOfWeek(dateTime);
                            result.Append(FormatDayOfWeek(dayOfWeek, tokenLen, dtfi));
                        }
                        bTimeOnly = false;
                        break;
                    case 'M':
                        // 
                        // tokenLen == 1 : Month as digits with no leading zero.
                        // tokenLen == 2 : Month as digits with leading zero for single-digit months.
                        // tokenLen == 3 : Month as a three-letter abbreviation.
                        // tokenLen >= 4 : Month as its full name.
                        //
                        tokenLen = ParseRepeatPattern(format, i, ch);
                        int month = cal.GetMonth(dateTime);
                        if (tokenLen <= 2)
                        {
                            if (isHebrewCalendar) {
                                // For Hebrew calendar, we need to convert numbers to Hebrew text for yyyy, MM, and dd values.
                                HebrewFormatDigits(result, month);
                            } else {                        
                                FormatDigits(result, month, tokenLen);
                            }
                        } 
                        else {
                            if (isHebrewCalendar) {
                                result.Append(FormatHebrewMonthName(dateTime, month, tokenLen, dtfi));
                            } else {             
                                if ((dtfi.FormatFlags & DateTimeFormatFlags.UseGenitiveMonth) != 0 && tokenLen >= 4) {
                                    result.Append(
                                        dtfi.internalGetMonthName(
                                            month, 
                                            IsUseGenitiveForm(format, i, tokenLen, 'd')? MonthNameStyles.Genitive : MonthNameStyles.Regular, 
                                            false));
                                } else {
                                result.Append(FormatMonth(month, tokenLen, dtfi));
                            }
                        }
                        }
                        bTimeOnly = false;
                        break;
                    case 'y':
                        // Notes about OS behavior:
                        // y: Always print (year % 100). No leading zero.
                        // yy: Always print (year % 100) with leading zero.
                        // yyy/yyyy/yyyyy/... : Print year value.  No leading zero.

                        int year = cal.GetYear(dateTime);
                        tokenLen = ParseRepeatPattern(format, i, ch);
                        if (dtfi.HasForceTwoDigitYears) {
                            FormatDigits(result, year, tokenLen <= 2 ? tokenLen : 2);
                        }
                        else if (cal.ID == Calendar.CAL_HEBREW) {
                            HebrewFormatDigits(result, year);
                        }
                        else {
                            if (tokenLen <= 2) {
                                FormatDigits(result, year % 100, tokenLen);
                            }
                            else {
                                String fmtPattern = "D" + tokenLen;
                                result.Append(year.ToString(fmtPattern, CultureInfo.InvariantCulture));
                            }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:67,代码来源:datetimeformat.cs


注:本文中的System.Globalization.DateTimeFormatInfo.internalGetMonthName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。