views:

29

answers:

1

I know that the version string generated by Visual Studio is based on the date/time of when the build was run. Given the partial version string "3856.24352" generated by Visual Studio, how can I translate that to the calendar day on which that build took place?

+3  A: 

The full version string is in the format major.minor.build.revision. The build part is the number of days since 1st January, 2000. The revision part is the number of seconds since midnight divided by 2 (see here for more info).

Assuming that your version strings are the auto-incrementing type, and that you have taken the build.revision part, you can turn it back into the date using:

string buildRevision = "3856.24352";

string[] parts = buildRevision.Split('.');
int build = int.Parse(parts[0]);
int revision = int.Parse(parts[1]);

DateTime dateTimeOfBuild = new DateTime(2000, 1, 1) 
                                + new TimeSpan(build, 0, 0, 0) 
                                + TimeSpan.FromSeconds(revision * 2);

This will give you a DateTime representing when the build was produced (which for your example is 23rd July, 2010 at 13:31:44).

adrianbanks