Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TimeSpanHeaderParser.cs
Go to the documentation of this file.
2
4
6{
7 internal static readonly TimeSpanHeaderParser Parser = new TimeSpanHeaderParser();
8
10 : base(supportsMultipleValues: false)
11 {
12 }
13
14 public override string ToString(object value)
15 {
16 return ((int)((TimeSpan)value).TotalSeconds).ToString(NumberFormatInfo.InvariantInfo);
17 }
18
19 protected override int GetParsedValueLength(string value, int startIndex, object storeValue, out object parsedValue)
20 {
21 parsedValue = null;
22 int numberLength = HttpRuleParser.GetNumberLength(value, startIndex, allowDecimal: false);
23 if (numberLength == 0 || numberLength > 10)
24 {
25 return 0;
26 }
27 int result = 0;
28 if (!HeaderUtilities.TryParseInt32(value, startIndex, numberLength, out result))
29 {
30 return 0;
31 }
32 parsedValue = new TimeSpan(0, 0, result);
33 return numberLength;
34 }
35}
static bool TryParseInt32(string value, out int result)
static readonly TimeSpanHeaderParser Parser
override int GetParsedValueLength(string value, int startIndex, object storeValue, out object parsedValue)
static int GetNumberLength(string input, int startIndex, bool allowDecimal)