/// <summary>Gets the executing assembly's compile date and time.</summary>
/// <remarks>
/// Assumes that in AssemblyInfo.cs, the version is specified as 1.0.* or the like,
/// with only 2 numbers specified; the next two are generated from the date.
/// version.Build is days since Jan. 1, 2000
/// version.Revision*2 is seconds since local midnight (NEVER daylight saving time)
/// Adapted from code at http://www.thescripts.com/forum/thread226146.html
/// </remarks>
/// <returns>The executing assembly's compile date and time</returns>
public static DateTime DateCompiled()
{
Version version = Assembly.GetExecutingAssembly().GetName().Version;
bool isDaylightSavingsTime = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now);
return new DateTime(2000, 1, 1).
AddDays(version.Build).
AddSeconds(version.Revision * 2).
AddHours(isDaylightSavingsTime ? 1 : 0);
}
0 Comments:
Post a Comment
<< Home