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)
[…ELIDED…]
$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 {
Write-Host
}
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.
No comments:
Post a Comment