Skip to content

Commit c0aa8a2

Browse files
committed
Fix (LogObject): Fix monthly rotation when last run occured on a month number greater than the current month number
Fixes #48
1 parent d569ee7 commit c0aa8a2

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)