Properly handle DST transitions in cron jobs (fixes #2366)

This commit is contained in:
mdecimus
2025-11-02 16:10:55 +01:00
parent 3d20a82354
commit c088110da1
4 changed files with 246 additions and 255 deletions

View File

@@ -59,7 +59,15 @@ impl SimpleCron {
}
};
(next - now).to_std().unwrap()
(next - now).to_std().unwrap_or_else(|_| self.as_duration())
}
pub fn as_duration(&self) -> Duration {
match self {
SimpleCron::Day { .. } => Duration::from_secs(24 * 60 * 60),
SimpleCron::Week { .. } => Duration::from_secs(7 * 24 * 60 * 60),
SimpleCron::Hour { .. } => Duration::from_secs(60 * 60),
}
}
}