明日(昨日)の日付を計算したい (Perl, Date::Simple)
明日、また昨日の日付を計算したい。
Date::Simpleモジュールを使用すると、非常に簡潔に記述することができる。
以下のプログラムの実行には、Date::Simpleモジュールのインストールが必要となっている。
;#
;#昨日、明日を求める
;#
use Date::Simple;
my $date = Date::Simple->new('1979-10-05');
my $tomorrow = $date->next;
my $yesterday = $date->prev;
print "明日:$tomorrow\n";
print "昨日:$yesterday\n";
○実行結果
明日:1979-10-06
昨日:1979-10-04
昨日:1979-10-04
■関連
明日(昨日)の日付を計算したい (Perl, time)
http://katsubemakito.net/cgiperl/2006/10/_perl_time.html
※time値を使用した場合の方法
日付の四則演算がしたい (Perl, Date::Simple)
http://katsubemakito.net/cgiperl/2006/10/_perl_datesimple.html
