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/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"; |