GetAllDateTimePatterns() public method

Returns all the standard patterns in which date and time values can be formatted.
public GetAllDateTimePatterns ( ) : string[]
return string[]
Exemplo n.º 1
0
        ////////////////////////////////////////////////////////////////////////////
        //
        // Given a DTFI, get all of the date words.
        //
        ////////////////////////////////////////////////////////////////////////////

        internal String[] GetDateWordsOfDTFI(DateTimeFormatInfo dtfi)
        {
            // Enumarate all LongDatePatterns, and get the DateWords and scan for month postfix.
            String[] datePatterns = dtfi.GetAllDateTimePatterns('D');
            int      i;

            for (i = 0; i < datePatterns.Length; i++)
            {
                ScanDateWord(datePatterns[i]);
            }
            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]);
            }
            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] = (String)m_dateWords[i];
                }
            }
            return(result);
        }
 internal string[] GetDateWordsOfDTFI(DateTimeFormatInfo dtfi)
 {
     foreach (string allDateTimePattern in dtfi.GetAllDateTimePatterns('D'))
     {
         this.ScanDateWord(allDateTimePattern);
     }
     foreach (string allDateTimePattern in dtfi.GetAllDateTimePatterns('d'))
     {
         this.ScanDateWord(allDateTimePattern);
     }
     foreach (string allDateTimePattern in dtfi.GetAllDateTimePatterns('y'))
     {
         this.ScanDateWord(allDateTimePattern);
     }
     this.ScanDateWord(dtfi.MonthDayPattern);
     foreach (string allDateTimePattern in dtfi.GetAllDateTimePatterns('T'))
     {
         this.ScanDateWord(allDateTimePattern);
     }
     foreach (string allDateTimePattern in dtfi.GetAllDateTimePatterns('t'))
     {
         this.ScanDateWord(allDateTimePattern);
     }
     string[] strArray = (string[])null;
     if (this.m_dateWords != null && this.m_dateWords.Count > 0)
     {
         strArray = new string[this.m_dateWords.Count];
         for (int index = 0; index < this.m_dateWords.Count; ++index)
         {
             strArray[index] = this.m_dateWords[index];
         }
     }
     return(strArray);
 }
Exemplo n.º 3
0
        ////////////////////////////////////////////////////////////////////////////
        //
        // Given a DTFI, get all of the date words from date patterns and time patterns.
        //
        ////////////////////////////////////////////////////////////////////////////

        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 // Token: 0x06002E15 RID: 11797 RVA: 0x000B0B48 File Offset: 0x000AED48
 internal string[] GetDateWordsOfDTFI(DateTimeFormatInfo dtfi)
 {
     string[] allDateTimePatterns = dtfi.GetAllDateTimePatterns('D');
     for (int i = 0; i < allDateTimePatterns.Length; i++)
     {
         this.ScanDateWord(allDateTimePatterns[i]);
     }
     allDateTimePatterns = dtfi.GetAllDateTimePatterns('d');
     for (int i = 0; i < allDateTimePatterns.Length; i++)
     {
         this.ScanDateWord(allDateTimePatterns[i]);
     }
     allDateTimePatterns = dtfi.GetAllDateTimePatterns('y');
     for (int i = 0; i < allDateTimePatterns.Length; i++)
     {
         this.ScanDateWord(allDateTimePatterns[i]);
     }
     this.ScanDateWord(dtfi.MonthDayPattern);
     allDateTimePatterns = dtfi.GetAllDateTimePatterns('T');
     for (int i = 0; i < allDateTimePatterns.Length; i++)
     {
         this.ScanDateWord(allDateTimePatterns[i]);
     }
     allDateTimePatterns = dtfi.GetAllDateTimePatterns('t');
     for (int i = 0; i < allDateTimePatterns.Length; i++)
     {
         this.ScanDateWord(allDateTimePatterns[i]);
     }
     string[] array = null;
     if (this.m_dateWords != null && this.m_dateWords.Count > 0)
     {
         array = new string[this.m_dateWords.Count];
         for (int i = 0; i < this.m_dateWords.Count; i++)
         {
             array[i] = this.m_dateWords[i];
         }
     }
     return(array);
 }
        [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);
        }
Exemplo n.º 7
0
 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);
 }
        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"));
        }
 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;
 }
		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;
								}
								default:
								{
									goto IL_153;
								}
							}
							break;
						}
					}
				}
			}
			allDateTimePatterns = dtfi.GetAllDateTimePatterns(format);
			array = new string[allDateTimePatterns.Length];
			for (int j = 0; j < allDateTimePatterns.Length; j++)
			{
				array[j] = DateTimeFormat.Format(dateTime, allDateTimePatterns[j], dtfi);
			}
			return array;
			IL_127:
			array = new string[]
			{
				DateTimeFormat.Format(dateTime, new string(new char[]
				{
					format
				}), dtfi)
			};
			return array;
			IL_153:
			throw new FormatException(Environment.GetResourceString("Format_InvalidString"));
		}