Limit birthday range with FROM and UNTIL

This commit is contained in:
Joscha 2021-12-06 11:01:21 +00:00
parent 5610f13683
commit c391d76690

View file

@ -8,10 +8,12 @@ use super::super::EntryKind;
impl<'a> CommandState<'a> { impl<'a> CommandState<'a> {
pub fn eval_birthday_spec(&mut self, spec: &BirthdaySpec) { pub fn eval_birthday_spec(&mut self, spec: &BirthdaySpec) {
// This could be optimized by restricting the range via FROM and UNTIL, let range = match self.limit_from_until(self.range) {
// but I don't think that kind of optimization will be necessary any Some(range) => range,
// time soon. None => return,
for year in self.range.years() { };
for year in range.years() {
let age = if spec.year_known { let age = if spec.year_known {
let age = year - spec.date.year(); let age = year - spec.date.year();
if age < 0 { if age < 0 {