Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TimeSpanParse.cs
Go to the documentation of this file.
1using System.Text;
2
4
5internal static class TimeSpanParse
6{
7 [Flags]
8 private enum TimeSpanStandardStyles : byte
9 {
10 None = 0,
11 Invariant = 1,
12 Localized = 2,
13 RequireFull = 4,
14 Any = 3
15 }
16
17 private enum TTT : byte
18 {
19 None,
20 End,
21 Num,
22 Sep,
24 }
25
26 private ref struct TimeSpanToken
27 {
28 internal TTT _ttt;
29
30 internal int _num;
31
32 internal int _zeroes;
33
35
37 : this(type, 0, 0, default(ReadOnlySpan<char>))
38 {
39 }
40
41 public TimeSpanToken(int number)
42 : this(TTT.Num, number, 0, default(ReadOnlySpan<char>))
43 {
44 }
45
46 public TimeSpanToken(int number, int leadingZeroes)
47 : this(TTT.Num, number, leadingZeroes, default(ReadOnlySpan<char>))
48 {
49 }
50
51 public TimeSpanToken(TTT type, int number, int leadingZeroes, ReadOnlySpan<char> separator)
52 {
53 _ttt = type;
54 _num = number;
55 _zeroes = leadingZeroes;
56 _sep = separator;
57 }
58
60 {
61 if (_num == 0)
62 {
63 return true;
64 }
65 if (_zeroes == 0 && _num > 9999999)
66 {
67 return false;
68 }
69 int num = (int)Math.Floor(Math.Log10(_num)) + 1 + _zeroes;
70 if (num == 7)
71 {
72 return true;
73 }
74 if (num < 7)
75 {
76 _num *= (int)Pow10(7 - num);
77 return true;
78 }
79 _num = (int)Math.Round((double)_num / (double)Pow10(num - 7), MidpointRounding.AwayFromZero);
80 return true;
81 }
82 }
83
84 private ref struct TimeSpanTokenizer
85 {
86 private readonly ReadOnlySpan<char> _value;
87
88 private int _pos;
89
90 internal bool EOL => _pos >= _value.Length - 1;
91
92 internal char NextChar
93 {
94 get
95 {
96 int num = ++_pos;
97 if ((uint)num >= (uint)_value.Length)
98 {
99 return '\0';
100 }
101 return _value[num];
102 }
103 }
104
106 : this(input, 0)
107 {
108 }
109
110 internal TimeSpanTokenizer(ReadOnlySpan<char> input, int startPosition)
111 {
112 _value = input;
113 _pos = startPosition;
114 }
115
117 {
118 int pos = _pos;
119 if (pos >= _value.Length)
120 {
121 return new TimeSpanToken(TTT.End);
122 }
123 int num = _value[pos] - 48;
124 if ((uint)num <= 9u)
125 {
126 int num2 = 0;
127 if (num == 0)
128 {
129 num2 = 1;
130 int num3;
131 while (true)
132 {
133 if (++_pos >= _value.Length || (uint)(num3 = _value[_pos] - 48) > 9u)
134 {
135 return new TimeSpanToken(TTT.Num, 0, num2, default(ReadOnlySpan<char>));
136 }
137 if (num3 != 0)
138 {
139 break;
140 }
141 num2++;
142 }
143 num = num3;
144 }
145 while (++_pos < _value.Length)
146 {
147 int num4 = _value[_pos] - 48;
148 if ((uint)num4 > 9u)
149 {
150 break;
151 }
152 num = num * 10 + num4;
153 if ((num & 0xF0000000u) != 0L)
154 {
155 return new TimeSpanToken(TTT.NumOverflow);
156 }
157 }
158 return new TimeSpanToken(TTT.Num, num, num2, default(ReadOnlySpan<char>));
159 }
160 int num5 = 1;
161 while (++_pos < _value.Length && (uint)(_value[_pos] - 48) > 9u)
162 {
163 num5++;
164 }
165 return new TimeSpanToken(TTT.Sep, 0, 0, _value.Slice(pos, num5));
166 }
167
168 internal void BackOne()
169 {
170 if (_pos > 0)
171 {
172 _pos--;
173 }
174 }
175 }
176
177 private ref struct TimeSpanRawInfo
178 {
180
181 internal int _tokenCount;
182
183 internal int _sepCount;
184
185 internal int _numCount;
186
188
190
191 private bool _posLocInit;
192
193 private bool _negLocInit;
194
195 private string _fullPosPattern;
196
197 private string _fullNegPattern;
198
200
202
204
206
208
210
212
214
216
218
220
222 {
223 get
224 {
225 if (!_posLocInit)
226 {
228 _posLoc.Init(_fullPosPattern, useInvariantFieldLengths: false);
229 _posLocInit = true;
230 }
231 return _posLoc;
232 }
233 }
234
236 {
237 get
238 {
239 if (!_negLocInit)
240 {
242 _negLoc.Init(_fullNegPattern, useInvariantFieldLengths: false);
243 _negLocInit = true;
244 }
245 return _negLoc;
246 }
247 }
248
250 {
251 if (_sepCount == 5 && _numCount == 4 && _literals0.EqualsOrdinal(pattern.Start) && _literals1.EqualsOrdinal(pattern.DayHourSep) && _literals2.EqualsOrdinal(pattern.HourMinuteSep) && _literals3.EqualsOrdinal(pattern.AppCompatLiteral))
252 {
253 return _literals4.EqualsOrdinal(pattern.End);
254 }
255 return false;
256 }
257
259 {
260 if (_sepCount == 4 && _numCount == 3 && _literals0.EqualsOrdinal(pattern.Start) && _literals1.EqualsOrdinal(pattern.HourMinuteSep) && _literals2.EqualsOrdinal(pattern.AppCompatLiteral))
261 {
262 return _literals3.EqualsOrdinal(pattern.End);
263 }
264 return false;
265 }
266
268 {
269 if (_sepCount == 6 && _numCount == 5 && _literals0.EqualsOrdinal(pattern.Start) && _literals1.EqualsOrdinal(pattern.DayHourSep) && _literals2.EqualsOrdinal(pattern.HourMinuteSep) && _literals3.EqualsOrdinal(pattern.MinuteSecondSep) && _literals4.EqualsOrdinal(pattern.SecondFractionSep))
270 {
271 return _literals5.EqualsOrdinal(pattern.End);
272 }
273 return false;
274 }
275
277 {
278 if (_sepCount == 2 && _numCount == 1 && _literals0.EqualsOrdinal(pattern.Start))
279 {
280 return _literals1.EqualsOrdinal(pattern.End);
281 }
282 return false;
283 }
284
286 {
287 if (_sepCount == 3 && _numCount == 2 && _literals0.EqualsOrdinal(pattern.Start) && _literals1.EqualsOrdinal(pattern.HourMinuteSep))
288 {
289 return _literals2.EqualsOrdinal(pattern.End);
290 }
291 return false;
292 }
293
295 {
296 if (_sepCount == 4 && _numCount == 3 && _literals0.EqualsOrdinal(pattern.Start) && _literals1.EqualsOrdinal(pattern.DayHourSep) && _literals2.EqualsOrdinal(pattern.HourMinuteSep))
297 {
298 return _literals3.EqualsOrdinal(pattern.End);
299 }
300 return false;
301 }
302
304 {
305 if (_sepCount == 4 && _numCount == 3 && _literals0.EqualsOrdinal(pattern.Start) && _literals1.EqualsOrdinal(pattern.HourMinuteSep) && _literals2.EqualsOrdinal(pattern.MinuteSecondSep))
306 {
307 return _literals3.EqualsOrdinal(pattern.End);
308 }
309 return false;
310 }
311
313 {
314 if (_sepCount == 5 && _numCount == 4 && _literals0.EqualsOrdinal(pattern.Start) && _literals1.EqualsOrdinal(pattern.DayHourSep) && _literals2.EqualsOrdinal(pattern.HourMinuteSep) && _literals3.EqualsOrdinal(pattern.MinuteSecondSep))
315 {
316 return _literals4.EqualsOrdinal(pattern.End);
317 }
318 return false;
319 }
320
322 {
323 if (_sepCount == 5 && _numCount == 4 && _literals0.EqualsOrdinal(pattern.Start) && _literals1.EqualsOrdinal(pattern.HourMinuteSep) && _literals2.EqualsOrdinal(pattern.MinuteSecondSep) && _literals3.EqualsOrdinal(pattern.SecondFractionSep))
324 {
325 return _literals4.EqualsOrdinal(pattern.End);
326 }
327 return false;
328 }
329
330 internal void Init(DateTimeFormatInfo dtfi)
331 {
332 _lastSeenTTT = TTT.None;
333 _tokenCount = 0;
334 _sepCount = 0;
335 _numCount = 0;
336 _fullPosPattern = dtfi.FullTimeSpanPositivePattern;
337 _fullNegPattern = dtfi.FullTimeSpanNegativePattern;
338 _posLocInit = false;
339 _negLocInit = false;
340 }
341
342 internal bool ProcessToken(ref TimeSpanToken tok, ref TimeSpanResult result)
343 {
344 switch (tok._ttt)
345 {
346 case TTT.Num:
347 if ((_tokenCount == 0 && !AddSep(default(ReadOnlySpan<char>), ref result)) || !AddNum(tok, ref result))
348 {
349 return false;
350 }
351 break;
352 case TTT.Sep:
353 if (!AddSep(tok._sep, ref result))
354 {
355 return false;
356 }
357 break;
358 case TTT.NumOverflow:
359 return result.SetOverflowFailure();
360 default:
361 return result.SetBadTimeSpanFailure();
362 }
363 _lastSeenTTT = tok._ttt;
364 return true;
365 }
366
367 private bool AddSep(ReadOnlySpan<char> sep, ref TimeSpanResult result)
368 {
369 if (_sepCount >= 6 || _tokenCount >= 11)
370 {
371 return result.SetBadTimeSpanFailure();
372 }
373 switch (_sepCount++)
374 {
375 case 0:
376 _literals0 = sep;
377 break;
378 case 1:
379 _literals1 = sep;
380 break;
381 case 2:
382 _literals2 = sep;
383 break;
384 case 3:
385 _literals3 = sep;
386 break;
387 case 4:
388 _literals4 = sep;
389 break;
390 default:
391 _literals5 = sep;
392 break;
393 }
394 _tokenCount++;
395 return true;
396 }
397
398 private bool AddNum(TimeSpanToken num, ref TimeSpanResult result)
399 {
400 if (_numCount >= 5 || _tokenCount >= 11)
401 {
402 return result.SetBadTimeSpanFailure();
403 }
404 switch (_numCount++)
405 {
406 case 0:
407 _numbers0 = num;
408 break;
409 case 1:
410 _numbers1 = num;
411 break;
412 case 2:
413 _numbers2 = num;
414 break;
415 case 3:
416 _numbers3 = num;
417 break;
418 default:
419 _numbers4 = num;
420 break;
421 }
422 _tokenCount++;
423 return true;
424 }
425 }
426
427 private ref struct TimeSpanResult
428 {
430
431 private readonly bool _throwOnFailure;
432
434
435 internal TimeSpanResult(bool throwOnFailure, ReadOnlySpan<char> originalTimeSpanString)
436 {
437 parsedTimeSpan = default(TimeSpan);
438 _throwOnFailure = throwOnFailure;
439 _originalTimeSpanString = originalTimeSpanString;
440 }
441
443 {
444 if (!_throwOnFailure)
445 {
446 return false;
447 }
449 }
450
451 internal bool SetBadQuoteFailure(char failingCharacter)
452 {
453 if (!_throwOnFailure)
454 {
455 return false;
456 }
457 throw new FormatException(SR.Format(SR.Format_BadQuote, failingCharacter));
458 }
459
461 {
462 if (!_throwOnFailure)
463 {
464 return false;
465 }
467 }
468
469 internal bool SetArgumentNullFailure(string argumentName)
470 {
471 if (!_throwOnFailure)
472 {
473 return false;
474 }
475 throw new ArgumentNullException(argumentName, SR.ArgumentNull_String);
476 }
477
478 internal bool SetOverflowFailure()
479 {
480 if (!_throwOnFailure)
481 {
482 return false;
483 }
485 }
486
487 internal bool SetBadTimeSpanFailure()
488 {
489 if (!_throwOnFailure)
490 {
491 return false;
492 }
494 }
495
496 internal bool SetBadFormatSpecifierFailure(char? formatSpecifierCharacter = null)
497 {
498 if (!_throwOnFailure)
499 {
500 return false;
501 }
502 throw new FormatException(SR.Format(SR.Format_BadFormatSpecifier, formatSpecifierCharacter));
503 }
504 }
505
506 private ref struct StringParser
507 {
509
510 private char _ch;
511
512 private int _pos;
513
514 private int _len;
515
516 internal void NextChar()
517 {
518 if (_pos < _len)
519 {
520 _pos++;
521 }
522 _ch = ((_pos < _len) ? _str[_pos] : '\0');
523 }
524
525 internal char NextNonDigit()
526 {
527 for (int i = _pos; i < _len; i++)
528 {
529 char c = _str[i];
530 if (c < '0' || c > '9')
531 {
532 return c;
533 }
534 }
535 return '\0';
536 }
537
539 {
540 result.parsedTimeSpan = default(TimeSpan);
541 _str = input;
542 _len = input.Length;
543 _pos = -1;
544 NextChar();
545 SkipBlanks();
546 bool flag = false;
547 if (_ch == '-')
548 {
549 flag = true;
550 NextChar();
551 }
552 long time;
553 if (NextNonDigit() == ':')
554 {
555 if (!ParseTime(out time, ref result))
556 {
557 return false;
558 }
559 }
560 else
561 {
562 if (!ParseInt(10675199, out var i, ref result))
563 {
564 return false;
565 }
566 time = i * 864000000000L;
567 if (_ch == '.')
568 {
569 NextChar();
570 if (!ParseTime(out var time2, ref result))
571 {
572 return false;
573 }
574 time += time2;
575 }
576 }
577 if (flag)
578 {
579 time = -time;
580 if (time > 0)
581 {
582 return result.SetOverflowFailure();
583 }
584 }
585 else if (time < 0)
586 {
587 return result.SetOverflowFailure();
588 }
589 SkipBlanks();
590 if (_pos < _len)
591 {
592 return result.SetBadTimeSpanFailure();
593 }
594 result.parsedTimeSpan = new TimeSpan(time);
595 return true;
596 }
597
598 internal bool ParseInt(int max, out int i, ref TimeSpanResult result)
599 {
600 i = 0;
601 int pos = _pos;
602 while (_ch >= '0' && _ch <= '9')
603 {
604 if ((i & 0xF0000000u) != 0L)
605 {
606 return result.SetOverflowFailure();
607 }
608 i = i * 10 + _ch - 48;
609 if (i < 0)
610 {
611 return result.SetOverflowFailure();
612 }
613 NextChar();
614 }
615 if (pos == _pos)
616 {
617 return result.SetBadTimeSpanFailure();
618 }
619 if (i > max)
620 {
621 return result.SetOverflowFailure();
622 }
623 return true;
624 }
625
626 internal bool ParseTime(out long time, ref TimeSpanResult result)
627 {
628 time = 0L;
629 if (!ParseInt(23, out var i, ref result))
630 {
631 return false;
632 }
633 time = i * 36000000000L;
634 if (_ch != ':')
635 {
636 return result.SetBadTimeSpanFailure();
637 }
638 NextChar();
639 if (!ParseInt(59, out i, ref result))
640 {
641 return false;
642 }
643 time += (long)i * 600000000L;
644 if (_ch == ':')
645 {
646 NextChar();
647 if (_ch != '.')
648 {
649 if (!ParseInt(59, out i, ref result))
650 {
651 return false;
652 }
653 time += (long)i * 10000000L;
654 }
655 if (_ch == '.')
656 {
657 NextChar();
658 int num = 10000000;
659 while (num > 1 && _ch >= '0' && _ch <= '9')
660 {
661 num /= 10;
662 time += (_ch - 48) * num;
663 NextChar();
664 }
665 }
666 }
667 return true;
668 }
669
670 internal void SkipBlanks()
671 {
672 while (_ch == ' ' || _ch == '\t')
673 {
674 NextChar();
675 }
676 }
677 }
678
679 internal static long Pow10(int pow)
680 {
681 return pow switch
682 {
683 0 => 1L,
684 1 => 10L,
685 2 => 100L,
686 3 => 1000L,
687 4 => 10000L,
688 5 => 100000L,
689 6 => 1000000L,
690 7 => 10000000L,
691 _ => (long)Math.Pow(10.0, pow),
692 };
693 }
694
695 private static bool TryTimeToTicks(bool positive, TimeSpanToken days, TimeSpanToken hours, TimeSpanToken minutes, TimeSpanToken seconds, TimeSpanToken fraction, out long result)
696 {
697 if (days._num > 10675199 || hours._num > 23 || minutes._num > 59 || seconds._num > 59 || !fraction.NormalizeAndValidateFraction())
698 {
699 result = 0L;
700 return false;
701 }
702 long num = ((long)days._num * 3600L * 24 + (long)hours._num * 3600L + (long)minutes._num * 60L + seconds._num) * 1000;
703 if (num > 922337203685477L || num < -922337203685477L)
704 {
705 result = 0L;
706 return false;
707 }
708 result = num * 10000 + fraction._num;
709 if (positive && result < 0)
710 {
711 result = 0L;
712 return false;
713 }
714 return true;
715 }
716
717 internal static TimeSpan Parse(ReadOnlySpan<char> input, IFormatProvider formatProvider)
718 {
719 TimeSpanResult result = new TimeSpanResult(throwOnFailure: true, input);
720 bool flag = TryParseTimeSpan(input, TimeSpanStandardStyles.Any, formatProvider, ref result);
721 return result.parsedTimeSpan;
722 }
723
724 internal static bool TryParse(ReadOnlySpan<char> input, IFormatProvider formatProvider, out TimeSpan result)
725 {
726 TimeSpanResult result2 = new TimeSpanResult(throwOnFailure: false, input);
727 if (TryParseTimeSpan(input, TimeSpanStandardStyles.Any, formatProvider, ref result2))
728 {
729 result = result2.parsedTimeSpan;
730 return true;
731 }
732 result = default(TimeSpan);
733 return false;
734 }
735
737 {
738 TimeSpanResult result = new TimeSpanResult(throwOnFailure: true, input);
739 bool flag = TryParseExactTimeSpan(input, format, formatProvider, styles, ref result);
740 return result.parsedTimeSpan;
741 }
742
744 {
745 TimeSpanResult result2 = new TimeSpanResult(throwOnFailure: false, input);
746 if (TryParseExactTimeSpan(input, format, formatProvider, styles, ref result2))
747 {
748 result = result2.parsedTimeSpan;
749 return true;
750 }
751 result = default(TimeSpan);
752 return false;
753 }
754
756 {
757 TimeSpanResult result = new TimeSpanResult(throwOnFailure: true, input);
758 bool flag = TryParseExactMultipleTimeSpan(input, formats, formatProvider, styles, ref result);
759 return result.parsedTimeSpan;
760 }
761
762 internal static bool TryParseExactMultiple(ReadOnlySpan<char> input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
763 {
764 TimeSpanResult result2 = new TimeSpanResult(throwOnFailure: false, input);
765 if (TryParseExactMultipleTimeSpan(input, formats, formatProvider, styles, ref result2))
766 {
767 result = result2.parsedTimeSpan;
768 return true;
769 }
770 result = default(TimeSpan);
771 return false;
772 }
773
775 {
776 input = input.Trim();
777 if (input.IsEmpty)
778 {
779 return result.SetBadTimeSpanFailure();
780 }
781 TimeSpanTokenizer timeSpanTokenizer = new TimeSpanTokenizer(input);
782 TimeSpanRawInfo raw = default(TimeSpanRawInfo);
783 raw.Init(DateTimeFormatInfo.GetInstance(formatProvider));
784 TimeSpanToken tok = timeSpanTokenizer.GetNextToken();
785 while (tok._ttt != TTT.End)
786 {
787 if (!raw.ProcessToken(ref tok, ref result))
788 {
789 return result.SetBadTimeSpanFailure();
790 }
791 tok = timeSpanTokenizer.GetNextToken();
792 }
793 if (!ProcessTerminalState(ref raw, style, ref result))
794 {
795 return result.SetBadTimeSpanFailure();
796 }
797 return true;
798 }
799
800 private static bool ProcessTerminalState(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result)
801 {
802 if (raw._lastSeenTTT == TTT.Num)
803 {
804 TimeSpanToken tok = default(TimeSpanToken);
805 tok._ttt = TTT.Sep;
806 if (!raw.ProcessToken(ref tok, ref result))
807 {
808 return result.SetBadTimeSpanFailure();
809 }
810 }
811 return raw._numCount switch
812 {
813 1 => ProcessTerminal_D(ref raw, style, ref result),
814 2 => ProcessTerminal_HM(ref raw, style, ref result),
815 3 => ProcessTerminal_HM_S_D(ref raw, style, ref result),
816 4 => ProcessTerminal_HMS_F_D(ref raw, style, ref result),
817 5 => ProcessTerminal_DHMSF(ref raw, style, ref result),
818 _ => result.SetBadTimeSpanFailure(),
819 };
820 }
821
822 private static bool ProcessTerminal_DHMSF(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result)
823 {
824 if (raw._sepCount != 6)
825 {
826 return result.SetBadTimeSpanFailure();
827 }
828 bool flag = (style & TimeSpanStandardStyles.Invariant) != 0;
829 bool flag2 = (style & TimeSpanStandardStyles.Localized) != 0;
830 bool flag3 = false;
831 bool flag4 = false;
832 if (flag)
833 {
835 {
836 flag4 = true;
837 flag3 = true;
838 }
839 if (!flag4 && raw.FullMatch(TimeSpanFormat.NegativeInvariantFormatLiterals))
840 {
841 flag4 = true;
842 flag3 = false;
843 }
844 }
845 if (flag2)
846 {
847 if (!flag4 && raw.FullMatch(raw.PositiveLocalized))
848 {
849 flag4 = true;
850 flag3 = true;
851 }
852 if (!flag4 && raw.FullMatch(raw.NegativeLocalized))
853 {
854 flag4 = true;
855 flag3 = false;
856 }
857 }
858 if (flag4)
859 {
860 if (!TryTimeToTicks(flag3, raw._numbers0, raw._numbers1, raw._numbers2, raw._numbers3, raw._numbers4, out var result2))
861 {
862 return result.SetOverflowFailure();
863 }
864 if (!flag3)
865 {
866 result2 = -result2;
867 if (result2 > 0)
868 {
869 return result.SetOverflowFailure();
870 }
871 }
872 result.parsedTimeSpan = new TimeSpan(result2);
873 return true;
874 }
875 return result.SetBadTimeSpanFailure();
876 }
877
878 private static bool ProcessTerminal_HMS_F_D(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result)
879 {
880 if (raw._sepCount != 5 || (style & TimeSpanStandardStyles.RequireFull) != 0)
881 {
882 return result.SetBadTimeSpanFailure();
883 }
884 bool flag = (style & TimeSpanStandardStyles.Invariant) != 0;
885 bool flag2 = (style & TimeSpanStandardStyles.Localized) != 0;
886 long result2 = 0L;
887 bool flag3 = false;
888 bool flag4 = false;
889 bool flag5 = false;
890 TimeSpanToken timeSpanToken = new TimeSpanToken(0);
891 if (flag)
892 {
893 if (raw.FullHMSFMatch(TimeSpanFormat.PositiveInvariantFormatLiterals))
894 {
895 flag3 = true;
896 flag4 = TryTimeToTicks(flag3, timeSpanToken, raw._numbers0, raw._numbers1, raw._numbers2, raw._numbers3, out result2);
897 flag5 = flag5 || !flag4;
898 }
899 if (!flag4 && raw.FullDHMSMatch(TimeSpanFormat.PositiveInvariantFormatLiterals))
900 {
901 flag3 = true;
902 flag4 = TryTimeToTicks(flag3, raw._numbers0, raw._numbers1, raw._numbers2, raw._numbers3, timeSpanToken, out result2);
903 flag5 = flag5 || !flag4;
904 }
905 if (!flag4 && raw.FullAppCompatMatch(TimeSpanFormat.PositiveInvariantFormatLiterals))
906 {
907 flag3 = true;
908 flag4 = TryTimeToTicks(flag3, raw._numbers0, raw._numbers1, raw._numbers2, timeSpanToken, raw._numbers3, out result2);
909 flag5 = flag5 || !flag4;
910 }
911 if (!flag4 && raw.FullHMSFMatch(TimeSpanFormat.NegativeInvariantFormatLiterals))
912 {
913 flag3 = false;
914 flag4 = TryTimeToTicks(flag3, timeSpanToken, raw._numbers0, raw._numbers1, raw._numbers2, raw._numbers3, out result2);
915 flag5 = flag5 || !flag4;
916 }
917 if (!flag4 && raw.FullDHMSMatch(TimeSpanFormat.NegativeInvariantFormatLiterals))
918 {
919 flag3 = false;
920 flag4 = TryTimeToTicks(flag3, raw._numbers0, raw._numbers1, raw._numbers2, raw._numbers3, timeSpanToken, out result2);
921 flag5 = flag5 || !flag4;
922 }
923 if (!flag4 && raw.FullAppCompatMatch(TimeSpanFormat.NegativeInvariantFormatLiterals))
924 {
925 flag3 = false;
926 flag4 = TryTimeToTicks(flag3, raw._numbers0, raw._numbers1, raw._numbers2, timeSpanToken, raw._numbers3, out result2);
927 flag5 = flag5 || !flag4;
928 }
929 }
930 if (flag2)
931 {
932 if (!flag4 && raw.FullHMSFMatch(raw.PositiveLocalized))
933 {
934 flag3 = true;
935 flag4 = TryTimeToTicks(flag3, timeSpanToken, raw._numbers0, raw._numbers1, raw._numbers2, raw._numbers3, out result2);
936 flag5 = flag5 || !flag4;
937 }
938 if (!flag4 && raw.FullDHMSMatch(raw.PositiveLocalized))
939 {
940 flag3 = true;
941 flag4 = TryTimeToTicks(flag3, raw._numbers0, raw._numbers1, raw._numbers2, raw._numbers3, timeSpanToken, out result2);
942 flag5 = flag5 || !flag4;
943 }
944 if (!flag4 && raw.FullAppCompatMatch(raw.PositiveLocalized))
945 {
946 flag3 = true;
947 flag4 = TryTimeToTicks(flag3, raw._numbers0, raw._numbers1, raw._numbers2, timeSpanToken, raw._numbers3, out result2);
948 flag5 = flag5 || !flag4;
949 }
950 if (!flag4 && raw.FullHMSFMatch(raw.NegativeLocalized))
951 {
952 flag3 = false;
953 flag4 = TryTimeToTicks(flag3, timeSpanToken, raw._numbers0, raw._numbers1, raw._numbers2, raw._numbers3, out result2);
954 flag5 = flag5 || !flag4;
955 }
956 if (!flag4 && raw.FullDHMSMatch(raw.NegativeLocalized))
957 {
958 flag3 = false;
959 flag4 = TryTimeToTicks(flag3, raw._numbers0, raw._numbers1, raw._numbers2, raw._numbers3, timeSpanToken, out result2);
960 flag5 = flag5 || !flag4;
961 }
962 if (!flag4 && raw.FullAppCompatMatch(raw.NegativeLocalized))
963 {
964 flag3 = false;
965 flag4 = TryTimeToTicks(flag3, raw._numbers0, raw._numbers1, raw._numbers2, timeSpanToken, raw._numbers3, out result2);
966 flag5 = flag5 || !flag4;
967 }
968 }
969 if (flag4)
970 {
971 if (!flag3)
972 {
973 result2 = -result2;
974 if (result2 > 0)
975 {
976 return result.SetOverflowFailure();
977 }
978 }
979 result.parsedTimeSpan = new TimeSpan(result2);
980 return true;
981 }
982 if (!flag5)
983 {
984 return result.SetBadTimeSpanFailure();
985 }
986 return result.SetOverflowFailure();
987 }
988
989 private static bool ProcessTerminal_HM_S_D(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result)
990 {
991 if (raw._sepCount != 4 || (style & TimeSpanStandardStyles.RequireFull) != 0)
992 {
993 return result.SetBadTimeSpanFailure();
994 }
995 bool flag = (style & TimeSpanStandardStyles.Invariant) != 0;
996 bool flag2 = (style & TimeSpanStandardStyles.Localized) != 0;
997 bool flag3 = false;
998 bool flag4 = false;
999 bool flag5 = false;
1000 TimeSpanToken timeSpanToken = new TimeSpanToken(0);
1001 long result2 = 0L;
1002 if (flag)
1003 {
1004 if (raw.FullHMSMatch(TimeSpanFormat.PositiveInvariantFormatLiterals))
1005 {
1006 flag3 = true;
1007 flag4 = TryTimeToTicks(flag3, timeSpanToken, raw._numbers0, raw._numbers1, raw._numbers2, timeSpanToken, out result2);
1008 flag5 = flag5 || !flag4;
1009 }
1010 if (!flag4 && raw.FullDHMMatch(TimeSpanFormat.PositiveInvariantFormatLiterals))
1011 {
1012 flag3 = true;
1013 flag4 = TryTimeToTicks(flag3, raw._numbers0, raw._numbers1, raw._numbers2, timeSpanToken, timeSpanToken, out result2);
1014 flag5 = flag5 || !flag4;
1015 }
1016 if (!flag4 && raw.PartialAppCompatMatch(TimeSpanFormat.PositiveInvariantFormatLiterals))
1017 {
1018 flag3 = true;
1019 flag4 = TryTimeToTicks(flag3, timeSpanToken, raw._numbers0, raw._numbers1, timeSpanToken, raw._numbers2, out result2);
1020 flag5 = flag5 || !flag4;
1021 }
1022 if (!flag4 && raw.FullHMSMatch(TimeSpanFormat.NegativeInvariantFormatLiterals))
1023 {
1024 flag3 = false;
1025 flag4 = TryTimeToTicks(flag3, timeSpanToken, raw._numbers0, raw._numbers1, raw._numbers2, timeSpanToken, out result2);
1026 flag5 = flag5 || !flag4;
1027 }
1028 if (!flag4 && raw.FullDHMMatch(TimeSpanFormat.NegativeInvariantFormatLiterals))
1029 {
1030 flag3 = false;
1031 flag4 = TryTimeToTicks(flag3, raw._numbers0, raw._numbers1, raw._numbers2, timeSpanToken, timeSpanToken, out result2);
1032 flag5 = flag5 || !flag4;
1033 }
1034 if (!flag4 && raw.PartialAppCompatMatch(TimeSpanFormat.NegativeInvariantFormatLiterals))
1035 {
1036 flag3 = false;
1037 flag4 = TryTimeToTicks(flag3, timeSpanToken, raw._numbers0, raw._numbers1, timeSpanToken, raw._numbers2, out result2);
1038 flag5 = flag5 || !flag4;
1039 }
1040 }
1041 if (flag2)
1042 {
1043 if (!flag4 && raw.FullHMSMatch(raw.PositiveLocalized))
1044 {
1045 flag3 = true;
1046 flag4 = TryTimeToTicks(flag3, timeSpanToken, raw._numbers0, raw._numbers1, raw._numbers2, timeSpanToken, out result2);
1047 flag5 = flag5 || !flag4;
1048 }
1049 if (!flag4 && raw.FullDHMMatch(raw.PositiveLocalized))
1050 {
1051 flag3 = true;
1052 flag4 = TryTimeToTicks(flag3, raw._numbers0, raw._numbers1, raw._numbers2, timeSpanToken, timeSpanToken, out result2);
1053 flag5 = flag5 || !flag4;
1054 }
1055 if (!flag4 && raw.PartialAppCompatMatch(raw.PositiveLocalized))
1056 {
1057 flag3 = true;
1058 flag4 = TryTimeToTicks(flag3, timeSpanToken, raw._numbers0, raw._numbers1, timeSpanToken, raw._numbers2, out result2);
1059 flag5 = flag5 || !flag4;
1060 }
1061 if (!flag4 && raw.FullHMSMatch(raw.NegativeLocalized))
1062 {
1063 flag3 = false;
1064 flag4 = TryTimeToTicks(flag3, timeSpanToken, raw._numbers0, raw._numbers1, raw._numbers2, timeSpanToken, out result2);
1065 flag5 = flag5 || !flag4;
1066 }
1067 if (!flag4 && raw.FullDHMMatch(raw.NegativeLocalized))
1068 {
1069 flag3 = false;
1070 flag4 = TryTimeToTicks(flag3, raw._numbers0, raw._numbers1, raw._numbers2, timeSpanToken, timeSpanToken, out result2);
1071 flag5 = flag5 || !flag4;
1072 }
1073 if (!flag4 && raw.PartialAppCompatMatch(raw.NegativeLocalized))
1074 {
1075 flag3 = false;
1076 flag4 = TryTimeToTicks(flag3, timeSpanToken, raw._numbers0, raw._numbers1, timeSpanToken, raw._numbers2, out result2);
1077 flag5 = flag5 || !flag4;
1078 }
1079 }
1080 if (flag4)
1081 {
1082 if (!flag3)
1083 {
1084 result2 = -result2;
1085 if (result2 > 0)
1086 {
1087 return result.SetOverflowFailure();
1088 }
1089 }
1090 result.parsedTimeSpan = new TimeSpan(result2);
1091 return true;
1092 }
1093 if (!flag5)
1094 {
1095 return result.SetBadTimeSpanFailure();
1096 }
1097 return result.SetOverflowFailure();
1098 }
1099
1100 private static bool ProcessTerminal_HM(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result)
1101 {
1102 if (raw._sepCount != 3 || (style & TimeSpanStandardStyles.RequireFull) != 0)
1103 {
1104 return result.SetBadTimeSpanFailure();
1105 }
1106 bool flag = (style & TimeSpanStandardStyles.Invariant) != 0;
1107 bool flag2 = (style & TimeSpanStandardStyles.Localized) != 0;
1108 bool flag3 = false;
1109 bool flag4 = false;
1110 if (flag)
1111 {
1113 {
1114 flag4 = true;
1115 flag3 = true;
1116 }
1117 if (!flag4 && raw.FullHMMatch(TimeSpanFormat.NegativeInvariantFormatLiterals))
1118 {
1119 flag4 = true;
1120 flag3 = false;
1121 }
1122 }
1123 if (flag2)
1124 {
1125 if (!flag4 && raw.FullHMMatch(raw.PositiveLocalized))
1126 {
1127 flag4 = true;
1128 flag3 = true;
1129 }
1130 if (!flag4 && raw.FullHMMatch(raw.NegativeLocalized))
1131 {
1132 flag4 = true;
1133 flag3 = false;
1134 }
1135 }
1136 if (flag4)
1137 {
1138 TimeSpanToken timeSpanToken = new TimeSpanToken(0);
1139 if (!TryTimeToTicks(flag3, timeSpanToken, raw._numbers0, raw._numbers1, timeSpanToken, timeSpanToken, out var result2))
1140 {
1141 return result.SetOverflowFailure();
1142 }
1143 if (!flag3)
1144 {
1145 result2 = -result2;
1146 if (result2 > 0)
1147 {
1148 return result.SetOverflowFailure();
1149 }
1150 }
1151 result.parsedTimeSpan = new TimeSpan(result2);
1152 return true;
1153 }
1154 return result.SetBadTimeSpanFailure();
1155 }
1156
1157 private static bool ProcessTerminal_D(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result)
1158 {
1159 if (raw._sepCount != 2 || (style & TimeSpanStandardStyles.RequireFull) != 0)
1160 {
1161 return result.SetBadTimeSpanFailure();
1162 }
1163 bool flag = (style & TimeSpanStandardStyles.Invariant) != 0;
1164 bool flag2 = (style & TimeSpanStandardStyles.Localized) != 0;
1165 bool flag3 = false;
1166 bool flag4 = false;
1167 if (flag)
1168 {
1170 {
1171 flag4 = true;
1172 flag3 = true;
1173 }
1174 if (!flag4 && raw.FullDMatch(TimeSpanFormat.NegativeInvariantFormatLiterals))
1175 {
1176 flag4 = true;
1177 flag3 = false;
1178 }
1179 }
1180 if (flag2)
1181 {
1182 if (!flag4 && raw.FullDMatch(raw.PositiveLocalized))
1183 {
1184 flag4 = true;
1185 flag3 = true;
1186 }
1187 if (!flag4 && raw.FullDMatch(raw.NegativeLocalized))
1188 {
1189 flag4 = true;
1190 flag3 = false;
1191 }
1192 }
1193 if (flag4)
1194 {
1195 TimeSpanToken timeSpanToken = new TimeSpanToken(0);
1196 if (!TryTimeToTicks(flag3, raw._numbers0, timeSpanToken, timeSpanToken, timeSpanToken, timeSpanToken, out var result2))
1197 {
1198 return result.SetOverflowFailure();
1199 }
1200 if (!flag3)
1201 {
1202 result2 = -result2;
1203 if (result2 > 0)
1204 {
1205 return result.SetOverflowFailure();
1206 }
1207 }
1208 result.parsedTimeSpan = new TimeSpan(result2);
1209 return true;
1210 }
1211 return result.SetBadTimeSpanFailure();
1212 }
1213
1215 {
1216 if (format.Length == 0)
1217 {
1218 return result.SetBadFormatSpecifierFailure();
1219 }
1220 if (format.Length == 1)
1221 {
1222 switch (format[0])
1223 {
1224 case 'T':
1225 case 'c':
1226 case 't':
1227 return TryParseTimeSpanConstant(input, ref result);
1228 case 'g':
1229 return TryParseTimeSpan(input, TimeSpanStandardStyles.Localized, formatProvider, ref result);
1230 case 'G':
1231 return TryParseTimeSpan(input, TimeSpanStandardStyles.Localized | TimeSpanStandardStyles.RequireFull, formatProvider, ref result);
1232 default:
1233 return result.SetBadFormatSpecifierFailure(format[0]);
1234 }
1235 }
1236 return TryParseByFormat(input, format, styles, ref result);
1237 }
1238
1240 {
1241 bool flag = false;
1242 bool flag2 = false;
1243 bool flag3 = false;
1244 bool flag4 = false;
1245 bool flag5 = false;
1246 int result2 = 0;
1247 int result3 = 0;
1248 int result4 = 0;
1249 int result5 = 0;
1250 int zeroes = 0;
1251 int result6 = 0;
1252 int i = 0;
1253 TimeSpanTokenizer tokenizer = new TimeSpanTokenizer(input, -1);
1254 int returnValue;
1255 for (; i < format.Length; i += returnValue)
1256 {
1257 char c = format[i];
1258 switch (c)
1259 {
1260 case 'h':
1261 returnValue = DateTimeFormat.ParseRepeatPattern(format, i, c);
1262 if (returnValue > 2 || flag2 || !ParseExactDigits(ref tokenizer, returnValue, out result3))
1263 {
1264 return result.SetInvalidStringFailure();
1265 }
1266 flag2 = true;
1267 break;
1268 case 'm':
1269 returnValue = DateTimeFormat.ParseRepeatPattern(format, i, c);
1270 if (returnValue > 2 || flag3 || !ParseExactDigits(ref tokenizer, returnValue, out result4))
1271 {
1272 return result.SetInvalidStringFailure();
1273 }
1274 flag3 = true;
1275 break;
1276 case 's':
1277 returnValue = DateTimeFormat.ParseRepeatPattern(format, i, c);
1278 if (returnValue > 2 || flag4 || !ParseExactDigits(ref tokenizer, returnValue, out result5))
1279 {
1280 return result.SetInvalidStringFailure();
1281 }
1282 flag4 = true;
1283 break;
1284 case 'f':
1285 returnValue = DateTimeFormat.ParseRepeatPattern(format, i, c);
1286 if (returnValue > 7 || flag5 || !ParseExactDigits(ref tokenizer, returnValue, returnValue, out zeroes, out result6))
1287 {
1288 return result.SetInvalidStringFailure();
1289 }
1290 flag5 = true;
1291 break;
1292 case 'F':
1293 returnValue = DateTimeFormat.ParseRepeatPattern(format, i, c);
1294 if (returnValue > 7 || flag5)
1295 {
1296 return result.SetInvalidStringFailure();
1297 }
1298 ParseExactDigits(ref tokenizer, returnValue, returnValue, out zeroes, out result6);
1299 flag5 = true;
1300 break;
1301 case 'd':
1302 {
1303 returnValue = DateTimeFormat.ParseRepeatPattern(format, i, c);
1304 if (returnValue > 8 || flag || !ParseExactDigits(ref tokenizer, (returnValue < 2) ? 1 : returnValue, (returnValue < 2) ? 8 : returnValue, out var _, out result2))
1305 {
1306 return result.SetInvalidStringFailure();
1307 }
1308 flag = true;
1309 break;
1310 }
1311 case '"':
1312 case '\'':
1313 {
1314 StringBuilder stringBuilder = StringBuilderCache.Acquire();
1315 if (!DateTimeParse.TryParseQuoteString(format, i, stringBuilder, out returnValue))
1316 {
1317 StringBuilderCache.Release(stringBuilder);
1318 return result.SetBadQuoteFailure(c);
1319 }
1320 if (!ParseExactLiteral(ref tokenizer, stringBuilder))
1321 {
1322 StringBuilderCache.Release(stringBuilder);
1323 return result.SetInvalidStringFailure();
1324 }
1325 StringBuilderCache.Release(stringBuilder);
1326 break;
1327 }
1328 case '%':
1329 {
1330 int num = DateTimeFormat.ParseNextChar(format, i);
1331 if (num >= 0 && num != 37)
1332 {
1333 returnValue = 1;
1334 break;
1335 }
1336 return result.SetInvalidStringFailure();
1337 }
1338 case '\\':
1339 {
1340 int num = DateTimeFormat.ParseNextChar(format, i);
1341 if (num >= 0 && tokenizer.NextChar == (ushort)num)
1342 {
1343 returnValue = 2;
1344 break;
1345 }
1346 return result.SetInvalidStringFailure();
1347 }
1348 default:
1349 return result.SetInvalidStringFailure();
1350 }
1351 }
1352 if (!tokenizer.EOL)
1353 {
1354 return result.SetBadTimeSpanFailure();
1355 }
1356 bool flag6 = (styles & TimeSpanStyles.AssumeNegative) == 0;
1357 if (TryTimeToTicks(flag6, new TimeSpanToken(result2), new TimeSpanToken(result3), new TimeSpanToken(result4), new TimeSpanToken(result5), new TimeSpanToken(result6, zeroes), out var result7))
1358 {
1359 if (!flag6)
1360 {
1361 result7 = -result7;
1362 }
1363 result.parsedTimeSpan = new TimeSpan(result7);
1364 return true;
1365 }
1366 return result.SetOverflowFailure();
1367 }
1368
1369 private static bool ParseExactDigits(ref TimeSpanTokenizer tokenizer, int minDigitLength, out int result)
1370 {
1371 int maxDigitLength = ((minDigitLength == 1) ? 2 : minDigitLength);
1372 int zeroes;
1373 return ParseExactDigits(ref tokenizer, minDigitLength, maxDigitLength, out zeroes, out result);
1374 }
1375
1376 private static bool ParseExactDigits(ref TimeSpanTokenizer tokenizer, int minDigitLength, int maxDigitLength, out int zeroes, out int result)
1377 {
1378 int num = 0;
1379 int num2 = 0;
1380 int i;
1381 for (i = 0; i < maxDigitLength; i++)
1382 {
1383 char nextChar = tokenizer.NextChar;
1384 if (nextChar < '0' || nextChar > '9')
1385 {
1386 tokenizer.BackOne();
1387 break;
1388 }
1389 num = num * 10 + (nextChar - 48);
1390 if (num == 0)
1391 {
1392 num2++;
1393 }
1394 }
1395 zeroes = num2;
1396 result = num;
1397 return i >= minDigitLength;
1398 }
1399
1400 private static bool ParseExactLiteral(ref TimeSpanTokenizer tokenizer, StringBuilder enquotedString)
1401 {
1402 for (int i = 0; i < enquotedString.Length; i++)
1403 {
1404 if (enquotedString[i] != tokenizer.NextChar)
1405 {
1406 return false;
1407 }
1408 }
1409 return true;
1410 }
1411
1413 {
1414 return default(StringParser).TryParse(input, ref result);
1415 }
1416
1417 private static bool TryParseExactMultipleTimeSpan(ReadOnlySpan<char> input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, ref TimeSpanResult result)
1418 {
1419 if (formats == null)
1420 {
1421 return result.SetArgumentNullFailure("formats");
1422 }
1423 if (input.Length == 0)
1424 {
1425 return result.SetBadTimeSpanFailure();
1426 }
1427 if (formats.Length == 0)
1428 {
1429 return result.SetNoFormatSpecifierFailure();
1430 }
1431 foreach (string text in formats)
1432 {
1433 if (string.IsNullOrEmpty(text))
1434 {
1435 return result.SetBadFormatSpecifierFailure();
1436 }
1437 TimeSpanResult result2 = new TimeSpanResult(throwOnFailure: false, input);
1438 if (TryParseExactTimeSpan(input, text, formatProvider, styles, ref result2))
1439 {
1440 result.parsedTimeSpan = result2.parsedTimeSpan;
1441 return true;
1442 }
1443 }
1444 return result.SetBadTimeSpanFailure();
1445 }
1446}
static int ParseNextChar(ReadOnlySpan< char > format, int pos)
static int ParseRepeatPattern(ReadOnlySpan< char > format, int pos, char patternChar)
static bool TryParseQuoteString(ReadOnlySpan< char > format, int pos, StringBuilder result, out int returnValue)
static readonly FormatLiterals NegativeInvariantFormatLiterals
static readonly FormatLiterals PositiveInvariantFormatLiterals
static bool ParseExactLiteral(ref TimeSpanTokenizer tokenizer, StringBuilder enquotedString)
static bool TryParseByFormat(ReadOnlySpan< char > input, ReadOnlySpan< char > format, TimeSpanStyles styles, ref TimeSpanResult result)
static TimeSpan Parse(ReadOnlySpan< char > input, IFormatProvider formatProvider)
static TimeSpan ParseExactMultiple(ReadOnlySpan< char > input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles)
static bool ProcessTerminal_HM(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result)
static bool TryParseExactMultiple(ReadOnlySpan< char > input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
static bool TryParseExact(ReadOnlySpan< char > input, ReadOnlySpan< char > format, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result)
static bool TryParseExactMultipleTimeSpan(ReadOnlySpan< char > input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, ref TimeSpanResult result)
static TimeSpan ParseExact(ReadOnlySpan< char > input, ReadOnlySpan< char > format, IFormatProvider formatProvider, TimeSpanStyles styles)
static bool TryParseExactTimeSpan(ReadOnlySpan< char > input, ReadOnlySpan< char > format, IFormatProvider formatProvider, TimeSpanStyles styles, ref TimeSpanResult result)
static bool ProcessTerminal_HM_S_D(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result)
static bool ProcessTerminalState(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result)
static bool TryParse(ReadOnlySpan< char > input, IFormatProvider formatProvider, out TimeSpan result)
static bool ProcessTerminal_HMS_F_D(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result)
static bool TryParseTimeSpanConstant(ReadOnlySpan< char > input, ref TimeSpanResult result)
static bool TryTimeToTicks(bool positive, TimeSpanToken days, TimeSpanToken hours, TimeSpanToken minutes, TimeSpanToken seconds, TimeSpanToken fraction, out long result)
static bool ProcessTerminal_DHMSF(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result)
static bool ParseExactDigits(ref TimeSpanTokenizer tokenizer, int minDigitLength, out int result)
static bool ParseExactDigits(ref TimeSpanTokenizer tokenizer, int minDigitLength, int maxDigitLength, out int zeroes, out int result)
static bool ProcessTerminal_D(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result)
static bool TryParseTimeSpan(ReadOnlySpan< char > input, TimeSpanStandardStyles style, IFormatProvider formatProvider, ref TimeSpanResult result)
static double Pow(double x, double y)
static decimal Round(decimal d)
Definition Math.cs:1096
static double Log10(double d)
static double Floor(double d)
static string Format_BadTimeSpan
Definition SR.cs:1340
static string Overflow_TimeSpanElementTooLarge
Definition SR.cs:1782
static string Format_BadQuote
Definition SR.cs:1338
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Format_BadFormatSpecifier
Definition SR.cs:1330
static string Format_InvalidString
Definition SR.cs:1354
static string ArgumentNull_String
Definition SR.cs:960
static string Format_NoFormatSpecifier
Definition SR.cs:1332
Definition SR.cs:7
static void Release(StringBuilder sb)
static StringBuilder Acquire(int capacity=16)
bool ParseTime(out long time, ref TimeSpanResult result)
bool TryParse(ReadOnlySpan< char > input, ref TimeSpanResult result)
bool ParseInt(int max, out int i, ref TimeSpanResult result)
bool FullDHMSMatch(TimeSpanFormat.FormatLiterals pattern)
bool AddSep(ReadOnlySpan< char > sep, ref TimeSpanResult result)
bool AddNum(TimeSpanToken num, ref TimeSpanResult result)
bool FullHMMatch(TimeSpanFormat.FormatLiterals pattern)
bool FullDHMMatch(TimeSpanFormat.FormatLiterals pattern)
bool FullMatch(TimeSpanFormat.FormatLiterals pattern)
bool FullHMSFMatch(TimeSpanFormat.FormatLiterals pattern)
bool FullHMSMatch(TimeSpanFormat.FormatLiterals pattern)
bool FullAppCompatMatch(TimeSpanFormat.FormatLiterals pattern)
bool FullDMatch(TimeSpanFormat.FormatLiterals pattern)
bool ProcessToken(ref TimeSpanToken tok, ref TimeSpanResult result)
bool PartialAppCompatMatch(TimeSpanFormat.FormatLiterals pattern)
TimeSpanResult(bool throwOnFailure, ReadOnlySpan< char > originalTimeSpanString)
readonly ReadOnlySpan< char > _originalTimeSpanString
bool SetBadFormatSpecifierFailure(char? formatSpecifierCharacter=null)
TimeSpanToken(int number, int leadingZeroes)
TimeSpanToken(TTT type, int number, int leadingZeroes, ReadOnlySpan< char > separator)
TimeSpanTokenizer(ReadOnlySpan< char > input, int startPosition)
ReadOnlySpan< T > Slice(int start)