Why 10675199.02:48:05.4775807 TimeSpan Maximum for CompilationSection?
Asked Answered
J

2

10

I was looking at the metadata for System.Web.Configuration.CompilationSection, and noticed the following attribute on the TimeSpan BatchTimeout property:

[TimeSpanValidator(MinValueString = "00:00:00", 
 MaxValueString = "10675199.02:48:05.4775807")]

Could someone explain why this is the allowed max value? TimeSpan itself has an upper limit, so why would there be another value validation, and why this number?

Joerg answered 28/5, 2010 at 23:15 Comment(0)
D
11

That is exactly the maximum value of TimeSpan. Quoting MSDN for TimeSpan.MaxValue:

The value of this field is equivalent to Int64.MaxValue ticks. The string representation of this value is positive 10675199.02:48:05.4775807.

Deangelis answered 28/5, 2010 at 23:18 Comment(0)
F
15

I think the accepted answer does not fully answer the question. It is indeed the same maximal value. And it's no coincidence. But why is the definition:

[TimeSpanValidator(MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")]

and not something like:

[TimeSpanValidator(TimeSpan.Zero, TimeSpan.MaxValue)]

?

Well simply put, it's because Attributes don't allow the second kind of definitions. They only allow compile time constants, because they are meta data that's compiled into the assembly.

Florentinoflorenza answered 6/2, 2014 at 16:57 Comment(1)
To expand on this, here is how the two are defined: public static readonly TimeSpan Zero = new TimeSpan(0);, public static readonly TimeSpan MaxValue = new TimeSpan(Int64.MaxValue);. They are instances of a type which are not available at compile time.Telephonist
D
11

That is exactly the maximum value of TimeSpan. Quoting MSDN for TimeSpan.MaxValue:

The value of this field is equivalent to Int64.MaxValue ticks. The string representation of this value is positive 10675199.02:48:05.4775807.

Deangelis answered 28/5, 2010 at 23:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.