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

◆ ToString() [2/2]

string System.Xml.Schema.XsdDuration.ToString ( DurationType durationType)
inlinepackage

Definition at line 249 of file XsdDuration.cs.

250 {
252 if (IsNegative)
253 {
254 stringBuilder.Append('-');
255 }
256 stringBuilder.Append('P');
257 if (durationType != DurationType.DayTimeDuration)
258 {
259 if (_years != 0)
260 {
261 stringBuilder.Append(XmlConvert.ToString(_years));
262 stringBuilder.Append('Y');
263 }
264 if (_months != 0)
265 {
266 stringBuilder.Append(XmlConvert.ToString(_months));
267 stringBuilder.Append('M');
268 }
269 }
270 if (durationType != DurationType.YearMonthDuration)
271 {
272 if (_days != 0)
273 {
274 stringBuilder.Append(XmlConvert.ToString(_days));
275 stringBuilder.Append('D');
276 }
277 if (_hours != 0 || _minutes != 0 || _seconds != 0 || Nanoseconds != 0)
278 {
279 stringBuilder.Append('T');
280 if (_hours != 0)
281 {
282 stringBuilder.Append(XmlConvert.ToString(_hours));
283 stringBuilder.Append('H');
284 }
285 if (_minutes != 0)
286 {
287 stringBuilder.Append(XmlConvert.ToString(_minutes));
288 stringBuilder.Append('M');
289 }
290 int num = Nanoseconds;
291 if (_seconds != 0 || num != 0)
292 {
293 stringBuilder.Append(XmlConvert.ToString(_seconds));
294 if (num != 0)
295 {
296 stringBuilder.Append('.');
297 int length = stringBuilder.Length;
299 int num2 = stringBuilder.Length - 1;
300 for (int num3 = num2; num3 >= length; num3--)
301 {
302 int num4 = num % 10;
303 stringBuilder[num3] = (char)(num4 + 48);
304 if (num2 == num3 && num4 == 0)
305 {
306 num2--;
307 }
308 num /= 10;
309 }
311 }
312 stringBuilder.Append('S');
313 }
314 }
315 if (stringBuilder[stringBuilder.Length - 1] == 'P')
316 {
317 stringBuilder.Append("T0S");
318 }
319 }
320 else if (stringBuilder[stringBuilder.Length - 1] == 'P')
321 {
322 stringBuilder.Append("0M");
323 }
324 return stringBuilder.ToString();
325 }

References System.Xml.Schema.XsdDuration._days, System.Xml.Schema.XsdDuration._hours, System.Xml.Schema.XsdDuration._minutes, System.Xml.Schema.XsdDuration._months, System.Xml.Schema.XsdDuration._seconds, System.Xml.Schema.XsdDuration._years, System.Xml.Dictionary, System.Xml.Schema.XsdDuration.IsNegative, System.length, System.Xml.Schema.XsdDuration.Nanoseconds, and System.Xml.XmlConvert.ToString().