Skip to content

Instantly share code, notes, and snippets.

@mumumu
Created June 9, 2010 15:01
Show Gist options
  • Save mumumu/431597 to your computer and use it in GitHub Desktop.
Save mumumu/431597 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
#
# marriage paper submit date calculation program.
# usage: perl marriage_date_calc.pl [year] [month] [date]
#
use strict;
use warnings;
#
# 6-you calc program
# get it from http://www3.biwako.ne.jp/~nobuaki/qreki/
#
use qreki;
use DateTime;
use utf8;
my $year = $ARGV[0];
my $month = $ARGV[1];
my $day = $ARGV[2];
my $from = DateTime->now( time_zone => 'Asia/Tokyo' );
my $to = DateTime->new(
time_zone => 'Asia/Tokyo',
year => $year,
month => $month,
day => $day,
hour => 0,
minute => 0,
second => 0,
);
my $taian_days = [];
my $count = 0;
while (1) {
my $tmp_year = $from->year;
my $tmp_month = $from->month;
my $tmp_day = $from->day;
if (qreki::get_rokuyou($tmp_year, $tmp_month, $tmp_day) eq 0) {
$taian_days->[$count] = [$tmp_year, $tmp_month, $tmp_day];
$count++;
}
last if ($tmp_year eq $year
&& $tmp_month eq $month
&& $tmp_day eq $day);
$from->add(days => 1);
}
my $random_count = int(rand($count));
print "marriage paper submit date is .... ";
print $taian_days->[$random_count][0] . "/";
print $taian_days->[$random_count][1] . "/";
print $taian_days->[$random_count][2] . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment