Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Init()

void System.Globalization.TimeSpanFormat.FormatLiterals.Init ( ReadOnlySpan< char > format,
bool useInvariantFieldLengths )
inlinepackage

Definition at line 64 of file TimeSpanFormat.cs.

65 {
66 dd = (hh = (mm = (ss = (ff = 0))));
67 _literals = new string[6];
68 for (int i = 0; i < _literals.Length; i++)
69 {
70 _literals[i] = string.Empty;
71 }
73 bool flag = false;
74 char c = '\'';
75 int num = 0;
76 for (int j = 0; j < format.Length; j++)
77 {
78 switch (format[j])
79 {
80 case '"':
81 case '\'':
82 if (flag && c == format[j])
83 {
84 if (num < 0 || num > 5)
85 {
86 return;
87 }
88 _literals[num] = stringBuilder.ToString();
89 stringBuilder.Length = 0;
90 flag = false;
91 }
92 else if (!flag)
93 {
94 c = format[j];
95 flag = true;
96 }
97 continue;
98 case '\\':
99 if (!flag)
100 {
101 j++;
102 continue;
103 }
104 break;
105 case 'd':
106 if (!flag)
107 {
108 num = 1;
109 dd++;
110 }
111 continue;
112 case 'h':
113 if (!flag)
114 {
115 num = 2;
116 hh++;
117 }
118 continue;
119 case 'm':
120 if (!flag)
121 {
122 num = 3;
123 mm++;
124 }
125 continue;
126 case 's':
127 if (!flag)
128 {
129 num = 4;
130 ss++;
131 }
132 continue;
133 case 'F':
134 case 'f':
135 if (!flag)
136 {
137 num = 5;
138 ff++;
139 }
140 continue;
141 }
142 stringBuilder.Append(format[j]);
143 }
145 if (useInvariantFieldLengths)
146 {
147 dd = 2;
148 hh = 2;
149 mm = 2;
150 ss = 2;
151 ff = 7;
152 }
153 else
154 {
155 if (dd < 1 || dd > 2)
156 {
157 dd = 2;
158 }
159 if (hh < 1 || hh > 2)
160 {
161 hh = 2;
162 }
163 if (mm < 1 || mm > 2)
164 {
165 mm = 2;
166 }
167 if (ss < 1 || ss > 2)
168 {
169 ss = 2;
170 }
171 if (ff < 1 || ff > 7)
172 {
173 ff = 7;
174 }
175 }
176 StringBuilderCache.Release(stringBuilder);
177 }
static void Release(StringBuilder sb)
static StringBuilder Acquire(int capacity=16)
override string ToString()
StringBuilder Append(char value, int repeatCount)

References System.Globalization.TimeSpanFormat.FormatLiterals._literals, System.Text.StringBuilderCache.Acquire(), System.Globalization.TimeSpanFormat.FormatLiterals.AppCompatLiteral, System.Text.StringBuilder.Append(), System.Globalization.TimeSpanFormat.FormatLiterals.dd, System.Globalization.TimeSpanFormat.FormatLiterals.ff, System.format, System.Globalization.TimeSpanFormat.FormatLiterals.hh, System.Globalization.TimeSpanFormat.FormatLiterals.MinuteSecondSep, System.Globalization.TimeSpanFormat.FormatLiterals.mm, System.Text.StringBuilderCache.Release(), System.Globalization.TimeSpanFormat.FormatLiterals.SecondFractionSep, System.Globalization.TimeSpanFormat.FormatLiterals.ss, and System.Text.StringBuilder.ToString().