Alex Rivera | Logout

Can I translate .net assembly versions to dates?

Asked 2009-11-19T22:20:52.547
16

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?

Edit
Report

2 Answers

26

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.

answered 2009-11-19T22:38:18.783
2

The version string has this format:

<major version>.<minor version>.<build number>.<revision>

and if you set the version as you've described, to 1.0.*:

The result of this is a build number set to the number of days since a random, designated start date and the revision based on the number of seconds since midnight.

The key here is "random". So, you can translate the revision to a time of day, but it sounds like you won't be able to resolve it to a date.

http://msdn.microsoft.com/en-us/library/ms998223.aspx

answered 2009-11-19T22:30:27.767

Your Answer