package GenerateurDate;

use strict;
use DateTime;
use DateTime::Duration;

my $numero_jour;
my $nb_dates;
my $date_courante;

BEGIN {
  $numero_jour = 0;
  $date_courante = DateTime->now();
  $date_courante->add(years => -12,
                      months => -6,
                      days => $numero_jour);
  $nb_dates = 2 + int(exp(0.001*$numero_jour));
}

sub _get_nb_dates {
  my $i = shift;
  return 2 + int((exp(0.003*$i)));
}

sub get_next_date {
  if ($nb_dates == 0) {
    $numero_jour++;
    $nb_dates = _get_nb_dates($numero_jour);
    $date_courante = DateTime->now();
    $date_courante->add(years => -7,
                        months => -4,
                        days => $numero_jour - 10);
  }
  $nb_dates--;
  return $date_courante->ymd();
}

1;
# eof #
