ラベル Class::Date の投稿を表示しています。 すべての投稿を表示
ラベル Class::Date の投稿を表示しています。 すべての投稿を表示

2005年3月16日水曜日

Class::Dateで扱えるのは1902年から2038年まで

search.cpan.org: Class::Date - Class for easy date and time manipulation

Class::Dateに「1900-01-01」を渡すとなぜか2038年になってしまうのでドキュメントを見直すとBUGS AND LIMITATIONSのセクションに以下の記述がありました。

>
This module uses the POSIX functions for date and time calculations, so it is not working for dates beyond 2038 and before 1902.
I don't know what systems support dates in 1902-1970 range, it may not work on your system. I know it works on the Linux glibc system with perl 5.6.1 and 5.7.2. I know it does not work with perl 5.005_03 (it may be the bug of the Time::Local module). Please report if you know any system where it does _not_ work with perl 5.6.1 or later.
I hope that someone will fix this with new time_t in libc. If you really need dates over 2038 and before 1902, you need to completely rewrite this module or use Date::Calc or other date modules.
<

時間関係はTime::Pieceを使った方がいいかも。


2005年2月24日木曜日

Class::Dateいい感じ

Class::DBIのWikiで使われてたのをみてから、時間を扱うモジュールとして、Class::Dateを利用しています。時間をオブジェクトとして扱うモジュールといえば、Time::PieceとかDate::Simpleが有名ですが、Class::Dateも結構いい感じです。Class:DBIと一緒に使うと便利で、has_aでDATETIME型のカラムにマッピングするのが以下の一行で行えます。

>

__PACKAGE__->has_a( modify_date => 'Class::Date' );
<