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

◆ TryToTimeSpan() [1/2]

Exception System.Xml.Schema.XsdDuration.TryToTimeSpan ( DurationType durationType,
out TimeSpan result )
inlinepackage

Definition at line 190 of file XsdDuration.cs.

191 {
192 Exception ex = null;
193 ulong num = 0uL;
194 checked
195 {
196 try
197 {
198 if (durationType != DurationType.DayTimeDuration)
199 {
200 num += ((ulong)_years + unchecked(checked((ulong)_months) / 12)) * 365;
201 num += unchecked(checked((ulong)_months) % 12) * 30;
202 }
203 if (durationType != DurationType.YearMonthDuration)
204 {
205 num += (ulong)_days;
206 num *= 24;
207 num += (ulong)_hours;
208 num *= 60;
209 num += (ulong)_minutes;
210 num *= 60;
211 num += (ulong)_seconds;
212 num *= 10000000;
213 num += unchecked(checked((ulong)Nanoseconds) / 100);
214 }
215 else
216 {
217 num *= 864000000000L;
218 }
219 if (IsNegative)
220 {
221 if (num == 9223372036854775808uL)
222 {
223 result = new TimeSpan(long.MinValue);
224 }
225 else
226 {
227 result = new TimeSpan(-(long)num);
228 }
229 }
230 else
231 {
232 result = new TimeSpan((long)num);
233 }
234 return null;
235 }
236 catch (OverflowException)
237 {
238 result = TimeSpan.MinValue;
239 return new OverflowException(System.SR.Format(System.SR.XmlConvert_Overflow, durationType, "TimeSpan"));
240 }
241 }
242 }
static string XmlConvert_Overflow
Definition SR.cs:372
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7

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.SR.Format(), System.Xml.Schema.XsdDuration.IsNegative, System.Xml.L, System.TimeSpan.MinValue, System.Xml.Schema.XsdDuration.Nanoseconds, System.Xml.TimeSpan, and System.SR.XmlConvert_Overflow.