YanoRyuichi.com/
Wiki
Blog
GitHub
Sandbox
開始行:
* Time::Piece(低機能だが軽い)[#n54937d4]
** Time::PieceとTime::Seconds [#fb84926b]
:Time::Piece|日付・時刻(タイムスタンプ)を表す。
:Time::Seconds|時間(秒)を表す。
** Time::Pieceオブジェクトを作る [#t922524b]
my $now = Time::Piece->localtime;
my $tp = Time::Piece->localtime->strptime( '2000-04-01 ...
say $tp->ymd; # "2000-04-01"
say $tp->hms; # "00:00:00"
*** 曜日を和名で [#ea85b1e2]
$tp->day_list(qw/日 月 火 水 木 金 土/);
say $tp->wdayname; # "土"
*** localtime() と gmtime() [#kfbe9280]
localtime()はタイムゾーンを考慮したTime::Pieceオブジェク...
my $gt = Time::Piece->gmtime( 25 * 60 * 60 );
say $gt->ymd; # 1970-01-02
say $gt->hms; # 01:00:00
my $lt = Time::Piece->localtime( 25 * 60 * 60 );
say $lt->ymd; # 1970-01-02
say $lt->hms; # 10:00:00
** Time::Seconds [#ufd881e7]
*** 翌日を求める [#xcdb354c]
my $tp = Time::Piece->localtime->strptime( '2000-04-01 0...
$tp += ONE_DAY;
say $tp->ymd; # 2000-04-02
say $tp->hms; # 00:00:00
*** 翌月は求まらない [#qc41f61e]
my $tp = Time::Piece->localtime->strptime( '2000-01-01 0...
$tp += ONE_MONTH;
say $tp->ymd; # 2000-01-31
say $tp->hms; # 10:29:04
ONE_MONTHが固定値(2629744)を使ってるから。翌月を求めた...
** 参考 [#bfdc9f53]
- http://search.cpan.org/perldoc?Time::Piece
- http://search.cpan.org/perldoc?Time::Seconds
終了行:
* Time::Piece(低機能だが軽い)[#n54937d4]
** Time::PieceとTime::Seconds [#fb84926b]
:Time::Piece|日付・時刻(タイムスタンプ)を表す。
:Time::Seconds|時間(秒)を表す。
** Time::Pieceオブジェクトを作る [#t922524b]
my $now = Time::Piece->localtime;
my $tp = Time::Piece->localtime->strptime( '2000-04-01 ...
say $tp->ymd; # "2000-04-01"
say $tp->hms; # "00:00:00"
*** 曜日を和名で [#ea85b1e2]
$tp->day_list(qw/日 月 火 水 木 金 土/);
say $tp->wdayname; # "土"
*** localtime() と gmtime() [#kfbe9280]
localtime()はタイムゾーンを考慮したTime::Pieceオブジェク...
my $gt = Time::Piece->gmtime( 25 * 60 * 60 );
say $gt->ymd; # 1970-01-02
say $gt->hms; # 01:00:00
my $lt = Time::Piece->localtime( 25 * 60 * 60 );
say $lt->ymd; # 1970-01-02
say $lt->hms; # 10:00:00
** Time::Seconds [#ufd881e7]
*** 翌日を求める [#xcdb354c]
my $tp = Time::Piece->localtime->strptime( '2000-04-01 0...
$tp += ONE_DAY;
say $tp->ymd; # 2000-04-02
say $tp->hms; # 00:00:00
*** 翌月は求まらない [#qc41f61e]
my $tp = Time::Piece->localtime->strptime( '2000-01-01 0...
$tp += ONE_MONTH;
say $tp->ymd; # 2000-01-31
say $tp->hms; # 10:29:04
ONE_MONTHが固定値(2629744)を使ってるから。翌月を求めた...
** 参考 [#bfdc9f53]
- http://search.cpan.org/perldoc?Time::Piece
- http://search.cpan.org/perldoc?Time::Seconds
ページ名: