Created
January 8, 2023 20:03
-
-
Save gustafe/bfeaa83277e3f0355b6790fd70ca087f to your computer and use it in GitHub Desktop.
Simple Perl program to count the number of month-day-weekday combinations since 1538 CE.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env perl | |
use Modern::Perl '2015'; | |
use DateTime; | |
### | |
use utf8; | |
binmode(STDOUT, ':encoding(UTF-8)'); | |
my $date = DateTime->new(year=>1583 , month=>1 ,day=>1); | |
my $stats; | |
say "collating..."; | |
while ($date <= DateTime->now()) { | |
push @{$stats->{$date->month}->{$date->day}->{$date->day_of_week}}, $date->\ | |
year; | |
$date->add(days=>1); | |
say $date->ymd if ($date->year % 25 == 0 and $date->month==1 and $date->day\ | |
==1); | |
} | |
say "printing..."; | |
for my $month (sort {$a<=>$b} keys %{$stats}) { | |
for my $day (sort {$a<=>$b} keys %{$stats->{$month}}) { | |
printf "%02d-%02d: ",$month,$day; | |
for my $wday (sort {$a<=>$b} keys %{$stats->{$month}{$day}}) { | |
printf "%02d ", scalar @{$stats->{$month}{$day}{$wday}}; | |
} | |
print "\n"; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired by https://boston.conman.org//2023/01/08.1 via https://lobste.rs/s/a4m4al/today_s_date_happens_more_frequently_on