TryParse() static private method

static private TryParse ( String s, DateTimeFormatInfo dtfi, DateTimeStyles styles, DateTime &result ) : bool
s String
dtfi DateTimeFormatInfo
styles DateTimeStyles
result DateTime
return bool
Exemplo n.º 1
0
        public static bool TryParse(ReadOnlySpan <char> input, out DateTimeOffset result)
        {
            bool parsed = DateTimeParse.TryParse(input, DateTimeFormatInfo.CurrentInfo, DateTimeStyles.None, out DateTime dateResult, out TimeSpan offset);

            result = new DateTimeOffset(dateResult.Ticks, offset);
            return(parsed);
        }
Exemplo n.º 2
0
        public static bool TryParse(ReadOnlySpan <char> input, IFormatProvider?formatProvider, DateTimeStyles styles, out DateTimeOffset result)
        {
            styles = ValidateStyles(styles, nameof(styles));
            bool parsed = DateTimeParse.TryParse(input, DateTimeFormatInfo.GetInstance(formatProvider), styles, out DateTime dateResult, out TimeSpan offset);

            result = new DateTimeOffset(dateResult.Ticks, offset);
            return(parsed);
        }
Exemplo n.º 3
0
        public static bool TryParse(string input, out DateTimeOffset result)
        {
            TimeSpan span;

            System.DateTime time;
            bool            flag = DateTimeParse.TryParse(input, DateTimeFormatInfo.CurrentInfo, DateTimeStyles.None, out time, out span);

            result = new DateTimeOffset(time.Ticks, span);
            return(flag);
        }
Exemplo n.º 4
0
        public static bool TryParse([NotNullWhen(true)] string?input, out DateTimeOffset result)
        {
            bool parsed = DateTimeParse.TryParse(input,
                                                 DateTimeFormatInfo.CurrentInfo,
                                                 DateTimeStyles.None,
                                                 out DateTime dateResult,
                                                 out TimeSpan offset);

            result = new DateTimeOffset(dateResult.Ticks, offset);
            return(parsed);
        }
Exemplo n.º 5
0
        public static bool TryParse(string input, IFormatProvider formatProvider, DateTimeStyles styles, out DateTimeOffset result)
        {
            TimeSpan span;

            System.DateTime time;
            styles = ValidateStyles(styles, "styles");
            bool flag = DateTimeParse.TryParse(input, DateTimeFormatInfo.GetInstance(formatProvider), styles, out time, out span);

            result = new DateTimeOffset(time.Ticks, span);
            return(flag);
        }
Exemplo n.º 6
0
        public static Boolean TryParse(String input, out DateTimeOffset result)
        {
            TimeSpan offset;
            DateTime dateResult;
            Boolean  parsed = DateTimeParse.TryParse(input,
                                                     DateTimeFormatInfo.CurrentInfo,
                                                     DateTimeStyles.None,
                                                     out dateResult,
                                                     out offset);

            result = new DateTimeOffset(dateResult.Ticks, offset);
            return(parsed);
        }
Exemplo n.º 7
0
        public static Boolean TryParse(String input, IFormatProvider formatProvider, DateTimeStyles styles, out DateTimeOffset result)
        {
            styles = ValidateStyles(styles, "styles");
            TimeSpan offset;
            DateTime dateResult;
            Boolean  parsed = DateTimeParse.TryParse(input,
                                                     DateTimeFormatInfo.GetInstance(formatProvider),
                                                     styles,
                                                     out dateResult,
                                                     out offset);

            result = new DateTimeOffset(dateResult.Ticks, offset);
            return(parsed);
        }
Exemplo n.º 8
0
        public static bool TryParse([NotNullWhen(true)] string?input, IFormatProvider?formatProvider, DateTimeStyles styles, out DateTimeOffset result)
        {
            styles = ValidateStyles(styles, nameof(styles));
            if (input == null)
            {
                result = default;
                return(false);
            }

            bool parsed = DateTimeParse.TryParse(input,
                                                 DateTimeFormatInfo.GetInstance(formatProvider),
                                                 styles,
                                                 out DateTime dateResult,
                                                 out TimeSpan offset);

            result = new DateTimeOffset(dateResult.Ticks, offset);
            return(parsed);
        }
Exemplo n.º 9
0
        public static Boolean TryParse(String input, IFormatProvider formatProvider, DateTimeStyles styles, out DateTimeOffset result)
        {
            styles = ValidateStyles(styles, nameof(styles));
            if (input == null)
            {
                result = default(DateTimeOffset);
                return(false);
            }

            TimeSpan offset;
            DateTime dateResult;
            Boolean  parsed = DateTimeParse.TryParse(input.AsReadOnlySpan(),
                                                     DateTimeFormatInfo.GetInstance(formatProvider),
                                                     styles,
                                                     out dateResult,
                                                     out offset);

            result = new DateTimeOffset(dateResult.Ticks, offset);
            return(parsed);
        }
Exemplo n.º 10
0
 public static bool TryParse(string s, IFormatProvider provider, DateTimeStyles styles, out DateTime result)
 {
     DateTimeFormatInfo.ValidateStyles(styles, "styles");
     return(DateTimeParse.TryParse(s, DateTimeFormatInfo.GetInstance(provider), styles, out result));
 }
Exemplo n.º 11
0
 public static bool TryParse(string s, out DateTime result)
 {
     return(DateTimeParse.TryParse(s, DateTimeFormatInfo.CurrentInfo, DateTimeStyles.None, out result));
 }