Exemple #1
0
 public static Boolean TryParseDateTimeExactMultiple(String value, String[] formats, IFormatProvider provider, DateTimeStyles styles, out DateTime result, out TimeSpan offset)
 {
     return(DateTimeParse.TryParseExactMultiple(value, formats, DateTimeFormatInfo.GetInstance(provider), styles, out result, out offset));
 }
        /// <summary>Main method called from TimeSpan.ToString.</summary>
        internal static string Format(TimeSpan value, string?format, IFormatProvider?formatProvider)
        {
            if (string.IsNullOrEmpty(format))
            {
                return(FormatC(value)); // formatProvider ignored, as "c" is invariant
            }

            if (format.Length == 1)
            {
                char c = format[0];

                if (c == 'c' || (c | 0x20) == 't') // special-case to optimize the default TimeSpan format
                {
                    return(FormatC(value));        // formatProvider ignored, as "c" is invariant
                }

                if ((c | 0x20) == 'g') // special-case to optimize the remaining 'g'/'G' standard formats
                {
                    return(FormatG(value, DateTimeFormatInfo.GetInstance(formatProvider), c == 'G' ? StandardFormat.G : StandardFormat.g));
                }

                throw new FormatException(SR.Format_InvalidString);
            }

            return(StringBuilderCache.GetStringAndRelease(FormatCustomized(value, format, DateTimeFormatInfo.GetInstance(formatProvider), result: null)));
        }
Exemple #3
0
 public static Boolean TryParseDateTimeExact(String value, String format, IFormatProvider provider, DateTimeStyles styles, out DateTime result)
 {
     return(DateTimeParse.TryParseExact(value, format, DateTimeFormatInfo.GetInstance(provider), styles, out result));
 }
Exemple #4
0
 public static DateTime ParseDateTimeExactMultiple(String value, String[] formats, IFormatProvider provider, DateTimeStyles styles)
 {
     return(DateTimeParse.ParseExactMultiple(value, formats, DateTimeFormatInfo.GetInstance(provider), styles));
 }
Exemple #5
0
 public static DateTime ParseDateTimeExact(String value, String format, IFormatProvider provider, DateTimeStyles styles, out TimeSpan offset)
 {
     return(DateTimeParse.ParseExact(value, format, DateTimeFormatInfo.GetInstance(provider), styles, out offset));
 }
Exemple #6
0
 public static DateTime ParseDateTime(String value, IFormatProvider provider, DateTimeStyles styles)
 {
     return(DateTimeParse.Parse(value, DateTimeFormatInfo.GetInstance(provider), styles));
 }
Exemple #7
0
 public static String FormatDateTime(DateTime value, String format, IFormatProvider provider, TimeSpan offSet)
 {
     return(DateTimeFormat.Format(value, format, DateTimeFormatInfo.GetInstance(provider), offSet));
 }