當前位置: 首頁>>代碼示例>>C#>>正文


C# DateTimeFormatInfo.GetAllDateTimePatterns方法代碼示例

本文整理匯總了C#中System.Globalization.DateTimeFormatInfo.GetAllDateTimePatterns方法的典型用法代碼示例。如果您正苦於以下問題:C# DateTimeFormatInfo.GetAllDateTimePatterns方法的具體用法?C# DateTimeFormatInfo.GetAllDateTimePatterns怎麽用?C# DateTimeFormatInfo.GetAllDateTimePatterns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Globalization.DateTimeFormatInfo的用法示例。


在下文中一共展示了DateTimeFormatInfo.GetAllDateTimePatterns方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetDateWordsOfDTFI

        [System.Security.SecurityCritical] // auto-generated
        #endif
        internal String[] GetDateWordsOfDTFI(DateTimeFormatInfo dtfi) {
            // Enumarate all LongDatePatterns, and get the DateWords and scan for month postfix.
            String[] datePatterns = dtfi.GetAllDateTimePatterns('D');
            int i;
            
            // Scan the long date patterns
            for (i = 0; i < datePatterns.Length; i++)
            {
                ScanDateWord(datePatterns[i]);
            }     

            // Scan the short date patterns
            datePatterns = dtfi.GetAllDateTimePatterns('d');
            for (i = 0; i < datePatterns.Length; i++)
            {
                ScanDateWord(datePatterns[i]);
            }
            // Scan the YearMonth patterns.
            datePatterns = dtfi.GetAllDateTimePatterns('y');
            for (i = 0; i < datePatterns.Length; i++)
            {
                ScanDateWord(datePatterns[i]);
            }                 

            // Scan the month/day pattern
            ScanDateWord(dtfi.MonthDayPattern);
            
            // Scan the long time patterns.
            datePatterns = dtfi.GetAllDateTimePatterns('T');
            for (i = 0; i < datePatterns.Length; i++)
            {
                ScanDateWord(datePatterns[i]);
            }                 

            // Scan the short time patterns.
            datePatterns = dtfi.GetAllDateTimePatterns('t');
            for (i = 0; i < datePatterns.Length; i++)
            {
                ScanDateWord(datePatterns[i]);
            }                 

            String[] result = null;
            if (m_dateWords != null && m_dateWords.Count > 0)
            {
                result = new String[m_dateWords.Count];
                for (i = 0; i < m_dateWords.Count; i++)
                {
                    result[i] = m_dateWords[i];
                }
            }
            return (result);
        }
開發者ID:ChuangYang,項目名稱:coreclr,代碼行數:54,代碼來源:DateTimeFormatInfoScanner.cs

示例2: GetAllDateTimes

 internal static String[] GetAllDateTimes(DateTime dateTime, char format, DateTimeFormatInfo dtfi)
 {
     Contract.Requires(dtfi != null);
     String [] allFormats    = null;
     String [] results       = null;
     
     switch (format)
     {
         case 'd':
         case 'D':                            
         case 'f':
         case 'F':
         case 'g':
         case 'G':
         case 'm':
         case 'M':
         case 't':
         case 'T':                
         case 'y':
         case 'Y':
             allFormats = dtfi.GetAllDateTimePatterns(format);
             results = new String[allFormats.Length];
             for (int i = 0; i < allFormats.Length; i++)
             {
                 results[i] = Format(dateTime, allFormats[i], dtfi);
             }
             break;
         case 'U':
             DateTime universalTime = dateTime.ToUniversalTime();
             allFormats = dtfi.GetAllDateTimePatterns(format);
             results = new String[allFormats.Length];
             for (int i = 0; i < allFormats.Length; i++)
             {
                 results[i] = Format(universalTime, allFormats[i], dtfi);
             }
             break;                
         //
         // The following ones are special cases because these patterns are read-only in
         // DateTimeFormatInfo.
         //
         case 'r':
         case 'R':
         case 'o':
         case 'O':
         case 's':
         case 'u':            
             results = new String[] {Format(dateTime, new String(new char[] {format}), dtfi)};
             break;   
         default:
             throw new FormatException(Environment.GetResourceString("Format_InvalidString"));
         
     }
     return (results);
 }
開發者ID:afrog33k,項目名稱:csnative,代碼行數:54,代碼來源:DateTimeFormat.cs

示例3: GetDateWordsOfDTFI

 internal string[] GetDateWordsOfDTFI(DateTimeFormatInfo dtfi)
 {
     int num;
     string[] allDateTimePatterns = dtfi.GetAllDateTimePatterns('D');
     for (num = 0; num < allDateTimePatterns.Length; num++)
     {
         this.ScanDateWord(allDateTimePatterns[num]);
     }
     allDateTimePatterns = dtfi.GetAllDateTimePatterns('d');
     for (num = 0; num < allDateTimePatterns.Length; num++)
     {
         this.ScanDateWord(allDateTimePatterns[num]);
     }
     allDateTimePatterns = dtfi.GetAllDateTimePatterns('y');
     for (num = 0; num < allDateTimePatterns.Length; num++)
     {
         this.ScanDateWord(allDateTimePatterns[num]);
     }
     this.ScanDateWord(dtfi.MonthDayPattern);
     allDateTimePatterns = dtfi.GetAllDateTimePatterns('T');
     for (num = 0; num < allDateTimePatterns.Length; num++)
     {
         this.ScanDateWord(allDateTimePatterns[num]);
     }
     allDateTimePatterns = dtfi.GetAllDateTimePatterns('t');
     for (num = 0; num < allDateTimePatterns.Length; num++)
     {
         this.ScanDateWord(allDateTimePatterns[num]);
     }
     string[] strArray2 = null;
     if ((this.m_dateWords != null) && (this.m_dateWords.Count > 0))
     {
         strArray2 = new string[this.m_dateWords.Count];
         for (num = 0; num < this.m_dateWords.Count; num++)
         {
             strArray2[num] = (string) this.m_dateWords[num];
         }
     }
     return strArray2;
 }
開發者ID:randomize,項目名稱:VimConfig,代碼行數:40,代碼來源:DateTimeFormatInfoScanner.cs

示例4: GetAllDateTimes

        internal static string[] GetAllDateTimes(DateTime dateTime, char format, DateTimeFormatInfo dtfi)
        {
            string[] allDateTimePatterns = null;
            string[] strArray2 = null;
            switch (format)
            {
                case 'D':
                case 'F':
                case 'G':
                case 'M':
                case 'T':
                case 'd':
                case 'f':
                case 'g':
                case 'Y':
                case 'm':
                case 't':
                case 'y':
                    allDateTimePatterns = dtfi.GetAllDateTimePatterns(format);
                    strArray2 = new string[allDateTimePatterns.Length];
                    for (int i = 0; i < allDateTimePatterns.Length; i++)
                    {
                        strArray2[i] = Format(dateTime, allDateTimePatterns[i], dtfi);
                    }
                    return strArray2;

                case 'O':
                case 'R':
                case 'o':
                case 'r':
                case 's':
                case 'u':
                    return new string[] { Format(dateTime, new string(new char[] { format }), dtfi) };

                case 'U':
                {
                    DateTime time = dateTime.ToUniversalTime();
                    allDateTimePatterns = dtfi.GetAllDateTimePatterns(format);
                    strArray2 = new string[allDateTimePatterns.Length];
                    for (int j = 0; j < allDateTimePatterns.Length; j++)
                    {
                        strArray2[j] = Format(time, allDateTimePatterns[j], dtfi);
                    }
                    return strArray2;
                }
            }
            throw new FormatException(Environment.GetResourceString("Format_InvalidString"));
        }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:48,代碼來源:DateTimeFormat.cs

示例5: GetAllDateTimes

		internal static string[] GetAllDateTimes(DateTime dateTime, char format, DateTimeFormatInfo dtfi)
		{
			string[] array = null;
			string[] allDateTimePatterns;
			if (format <= 'U')
			{
				switch (format)
				{
					case 'D':
					case 'F':
					case 'G':
					{
						break;
					}
					case 'E':
					{
						goto IL_153;
					}
					default:
					{
						switch (format)
						{
							case 'M':
							case 'T':
							{
								break;
							}
							case 'N':
							case 'P':
							case 'Q':
							case 'S':
							{
								goto IL_153;
							}
							case 'O':
							case 'R':
							{
								goto IL_127;
							}
							case 'U':
							{
								DateTime dateTime2 = dateTime.ToUniversalTime();
								allDateTimePatterns = dtfi.GetAllDateTimePatterns(format);
								array = new string[allDateTimePatterns.Length];
								for (int i = 0; i < allDateTimePatterns.Length; i++)
								{
									array[i] = DateTimeFormat.Format(dateTime2, allDateTimePatterns[i], dtfi);
								}
								return array;
							}
							default:
							{
								goto IL_153;
							}
						}
						break;
					}
				}
			}
			else
			{
				if (format != 'Y')
				{
					switch (format)
					{
						case 'd':
						case 'f':
						case 'g':
						{
							break;
						}
						case 'e':
						{
							goto IL_153;
						}
						default:
						{
							switch (format)
							{
								case 'm':
								case 't':
								case 'y':
								{
									break;
								}
								case 'n':
								case 'p':
								case 'q':
								case 'v':
								case 'w':
								case 'x':
								{
									goto IL_153;
								}
								case 'o':
								case 'r':
								case 's':
								case 'u':
								{
									goto IL_127;
//.........這裏部分代碼省略.........
開發者ID:ChristianWulf,項目名稱:CSharpKDMDiscoverer,代碼行數:101,代碼來源:DateTimeFormat.cs


注:本文中的System.Globalization.DateTimeFormatInfo.GetAllDateTimePatterns方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。