Skip to content

Commit f89d147

Browse files
Merge pull request #49 from theohbrothers/fix/logobject-fix-monthly-rotation-when-last-run-occured-on-a-month-number-greater-than-the-current-month-number
Fix (LogObject): Fix monthly rotation when last run occured on a month number greater than the current month number
2 parents d569ee7 + c0aa8a2 commit f89d147

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Log-Rotate/classes/New-LogObject.ps1

+4
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,10 @@ function New-LogObject {
719719
if ($_now_dt.Month -gt $_last_dt.Month) {
720720
Write-Verbose "Time interval over. This is the first time logrotate is run this month. "
721721
return $true
722+
}elseif ($_now_dt.Year -gt $_last_dt.Year) {
723+
# The case where the current year is a new year
724+
Write-Verbose "Time interval over. Last rotation occured last year. Last rotation: $($_last_dt.ToString('s'))"
725+
return $true
722726
}else {
723727
Write-Verbose "Time interval not over. Last rotation already occured this month. Last rotation: $($_last_dt.ToString('s'))"
724728
}

0 commit comments

Comments
 (0)