Created
December 9, 2016 00:28
-
-
Save SidShetye/4aaf1172dfa3128b6d62078e25159b04 to your computer and use it in GitHub Desktop.
In .NET builds auto-increment if your code specified build versions like "1.2.*". This powershell script goes the reverse and helps find the date of release given a version number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param( | |
[Version] $Version ="1.2.5678.6432" | |
) | |
# Usage as 'Get-BuildDateFromVersion.ps1 -Version 1.2.3.4' | |
# Intentionally written in verbose mode, line by line | |
# From https://msdn.microsoft.com/en-us/library/system.reflection.assemblyversionattribute.aspx and | |
# http://stackoverflow.com/questions/13943456/what-is-the-formula-in-net-for-wildcard-version-numbers | |
# Build = DateTime.Today.Subtract(new DateTime(2000, 1, 1)).Days; | |
# Revision = (int)DateTime.Now.Subtract(DateTime.Today).TotalSeconds / 2; | |
# Start at epoc | |
$date = New-Object System.DateTime 2000,1,1 | |
# Add days (build) | |
$date = $date.AddDays($Version.Build) | |
# Add seconds x 2 | |
$date = $date.AddSeconds($Version.Revision * 2) | |
Write-Host "Build time: " $date.ToString("F") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment