Skip to content

Instantly share code, notes, and snippets.

@n7st
Last active September 22, 2016 18:45
Show Gist options
  • Save n7st/e5e2d280debec4aa018c858a6e118723 to your computer and use it in GitHub Desktop.
Save n7st/e5e2d280debec4aa018c858a6e118723 to your computer and use it in GitHub Desktop.
DateMath.pl
#!/usr/bin/env perl
use strict;
use warnings;
use DateTime;
use Data::Printer;
my $start = DateTime->new(month => 02, year => 16);
my $end = DateTime->new(month => 10, year => 16);
for (
my $date = $start;
$date->year != $end->year || $date->month <= $end->month;
$date->add(months => 1)
) {
printf("Y: %d m: %d, Start: %d, End: %d\n",
$date->year,
$date->month,
1,
DateTime->last_day_of_month(month => $date->month, year => $date->year)->day,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment