Friday, May 1, 2015

Huh... It's Not Completely Sucktacular

So, I'm not a complete curmudgeon, when it comes to tech. Doing time-math is a lot easier with PowerShell than bash:
$DaysBack = 14
$DateHorizon =  ([DateTime]::Now).AddDays(-$DaysBack)
$SnapId = $SnapStruct.SnapshotId
$SnapStart = $SnapStruct.StartTime
Write-Host -NoNewline "Found snapshot: $SnapId (started @ ${SnapStart})"

if ([DateTime]::Compare($DateHorizon, $SnapStart) -gt 0) {
    Write-Host " - $SnapId is older than defined horizon"
} else {
No having to ass about with having to convert from LOCALE-time to epoch-time to do the math or having to convert the result from epoch-time back to LOCALE-time.