⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 infinite.pm

📁 1. 记录每个帖子的访问人情况
💻 PM
字号:
package DateTime::Infinite;use strict;use DateTime;use DateTime::TimeZone;use base qw(DateTime);foreach my $m ( qw( set set_time_zone truncate ) ){    no strict 'refs';    *{"DateTime::Infinite::$m"} =        sub { return $_[0] };}sub is_finite { 0 }sub is_infinite { 1 }sub _rd2ymd{    return $_[2] ? ($_[1]) x 7 : ($_[1]) x 3;}sub _seconds_as_components{    return ($_[1]) x 3;}package DateTime::Infinite::Future;use base qw(DateTime::Infinite);{    my $Pos = bless { utc_rd_days => DateTime::INFINITY,                      utc_rd_secs => DateTime::INFINITY,                      local_rd_days => DateTime::INFINITY,                      local_rd_secs => DateTime::INFINITY,                      rd_nanosecs => DateTime::INFINITY,                      tz          => DateTime::TimeZone->new( name => 'floating' ),                    }, __PACKAGE__;    $Pos->_calc_utc_rd;    $Pos->_calc_local_rd;    sub new { $Pos }}package DateTime::Infinite::Past;use base qw(DateTime::Infinite);{    my $Neg = bless { utc_rd_days => DateTime::NEG_INFINITY,                      utc_rd_secs => DateTime::NEG_INFINITY,                      local_rd_days => DateTime::NEG_INFINITY,                      local_rd_secs => DateTime::NEG_INFINITY,                      rd_nanosecs => DateTime::NEG_INFINITY,                      tz          => DateTime::TimeZone->new( name => 'floating' ),                    }, __PACKAGE__;    $Neg->_calc_utc_rd;    $Neg->_calc_local_rd;    sub new { $Neg }}1;__END__=head1 NAMEDateTime::Infinite - Infinite past and future DateTime objects=head1 SYNOPSIS  my $future = DateTime::Infinite::Future->new;  my $past   = DateTime::Infinite::Past->new;=head1 DESCRIPTIONThis module provides two L<DateTime.pm|DateTime> subclasses,C<DateTime::Infinite::Future> and C<DateTime::Infinite::Past>.The objects are in the "floating" timezone, and this cannot bechanged.=head1 BUGSThere seem to be lots of problems when dealing with infinite numberson Win32.  This may be a problem with this code, Perl, or Win32's IEEEmath implementation.  Either way, the module may not be well-behavedon Win32 operating systems.=head1 METHODSThe only constructor for these two classes is the C<new()> method, asshown in the L<SYNOPSIS|/SYNOPSIS>.  This method takes no parameters.All "get" methods in this module simply return infinity, positive ornegative.  If the method is expected to return a string, it return thestring representation of positive or negative infinity used by yoursystem.  For example, on my system calling C<year()> returns a numberwhich when printed appears either "inf" or "-inf".The object is not mutable, so the C<set()>, C<set_time_zone()>, andC<truncate()> methods are all do-nothing methods that simply returnthe object they are called with.Obviously, the C<is_finite()> method returns false and theC<is_infinite()> method returns true.=head1 AUTHORDave Rolsky <autarch@urth.org>=head1 COPYRIGHTCopyright (c) 2003 David Rolsky.  All rights reserved.  This programis free software; you can redistribute it and/or modify it under thesame terms as Perl itself.The full text of the license can be found in the LICENSE file includedwith this module.=head1 SEE ALSOdatetime@perl.org mailing listhttp://datetime.perl.org/=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -