100 || $startYear + $years > 10000) throw new InvalidArgumentException('Invalid calendar interval.'); $months = [1=>'Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro']; $weekdays = [1=>'Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo']; $date = new DateTimeImmutable(sprintf('%04d-01-01', $startYear), new DateTimeZone('Africa/Maputo')); while ((int)$date->format('Y') < $startYear + $years) { $month = (int)$date->format('n'); $weekday = (int)$date->format('N'); yield ['data_id'=>(int)$date->format('Ymd'), 'data_completa'=>$date->format('Y-m-d'), 'dia_semana'=>$weekday, 'nome_dia_semana'=>$weekdays[$weekday], 'dia_mes'=>(int)$date->format('j'), 'mes'=>$month, 'nome_mes'=>$months[$month], 'trimestre'=>intdiv($month-1,3)+1, 'ano'=>(int)$date->format('Y'), 'ano_mes'=>$date->format('Y-m'), 'eh_dia_util'=>$weekday<=5, 'eh_feriado'=>false, 'semestre'=>$month<=6?1:2]; $date = $date->modify('+1 day'); } } }