Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I translate .net assembly versions to dates?

Tags:

.net

All of my .NET assemblies uses the 1.0.* format for their version numbers. Supposedly the * gets replaced with the current date and time, translated into a number. What is the formula to translate it back into a date and time?

like image 485
Jonathan Allen Avatar asked Nov 19 '09 22:11

Jonathan Allen


1 Answers

The AssemblyVersionAttribute documentation states that:

The default build number increments daily. The default revision number is the number of seconds since midnight local time (without taking into account time zone adjustments for daylight saving time), divided by 2.

The reference date for the build number isn't specified. In practice, I've found this to be 1 January 2000.

The date can therefore be reconstructed as follows:

var result = new DateTime(2000, 1, 1);
result = result.AddDays(buildNumber);
result = result.AddSeconds(revision * 2);

Since the reference date isn't documented, it can't be guaranteed to always remain unchanged.

like image 126
Phil Ross Avatar answered Oct 04 '22 21:10

Phil Ross