=encoding euc-jp =head1 NAME Date::Simple - 簡単な日付オブジェクト =head1 概要 my $date = Date::Simple->new('1972-01-17'); my $year = $date->year; my $month = $date->month; my $day = $date->day; my $date2 = Date::Simple->new($year, $month, $day); my $today = Date::Simple->new; my $tomorrow = $today + 1; print "Tomorrow's date (in ISO 8601 format) is $tomorrow.\n"; if ($tomorrow->year != $today->year) { print "Today is New Year's Eve!\n"; } if ($today > $tomorrow) { die "warp in space-time continuum"; } # you can also do this: ($date cmp "2001-07-01") # and this ($date <=> [2001, 7, 1]) =head1 説明 このモジュールは、簡単な日付オブジェクトを作ります。 Unixの時間の範囲の日付しか扱いません。 このモジュールは、不当な日付のオブジェクトを作ることを許しません。 不当な日付で作ろうとすると、undefを返します。 =head1 コンストラクタ =head2 new my $date = Date::Simple->new('1972-01-17'); my $otherdate = Date::Simple->new(2000, 12, 25); 渡された値が妥当な日付を指定していたら、Cメソッドは、日付オブジェクトを返します。 渡された値が不正であれば、メソッドは、undefを返します。 =head1 インスタンスメソッド =head2 next my $tomorrow = $today->next; 明日に相当するオブジェクトを返します。 =head2 prev my $yesterday = $today->prev; 昨日に相当するオブジェクトを返します。 =head2 year my $year = $date->year; 日付オブジェクトが持っている日付の年を返します。 =head2 month my $month = $date->month; 日付オブジェクトが持っている日付の月を返します。 =head2 day my $day = $date->day; 日付オブジェクトが持っている日付の日を返します。 =head2 format これらの関数は同等です。日付を表す文字列を、指定されたフォーマットで返します。 パラメータを渡さなければ、ISO8601フォーマットが返ります。 my $change_date = $date->format("%d %b %y"); my $iso_date1 = $date->format("%Y-%m-%d"); my $iso_date2 = $date->format; フォーマットのパラメータは、srrftime(3)に渡すものと、似ています。 これは私たちが日付をフォーマットするためにそれを実際にstrftimeに渡すからです。 =head1 演算子 Date:Simpleインスタンスと一緒に、いくつかの演算子を使うことが出来ます。 =over 4 =item + += と、-= 演算子を使って、日数によって、日付をインクリメント、デクリメント出来ます。 =item * +と-演算子を使うことで、日数で、新しい日付オフセットを生成出来ます。 =item * 日付の間の日数を見つけるために2つの日付を引くことができます。 =item * 算術/文字列比較演算子を使って、2つの日付を比較することが出来ます。 =item * ISO 8601(例:2000-01-17)で、指定された形式で、 日付オブジェクトを直接に文字列に挿入できます。 =back =head1 著者 Marty Pauley Emarty@kasei.comE =head1 著作権 Copyright (C) 2001 Kasei This program is free software; you can redistribute it and/or modify it under the terms of either: a) the GNU General Public License; either version 2 of the License, or (at your option) any later version. b) the Perl Artistic License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.