summaryrefslogtreecommitdiff
path: root/lib/Time
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-10-28 17:33:49 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-10-28 17:33:49 +0000
commita1f333424726116552fec059c74f91eae67b2820 (patch)
tree1acab5523263822da5f4b240529b9769bfba5891 /lib/Time
parent52b0428e3435010996923055059a0bfd91b64619 (diff)
downloadperl-a1f333424726116552fec059c74f91eae67b2820.tar.gz
remove C<use Time::Local 'no_range_check'> misfeature (global
can still be directly set) p4raw-id: //depot/perl@4481
Diffstat (limited to 'lib/Time')
-rw-r--r--lib/Time/Local.pm35
1 files changed, 13 insertions, 22 deletions
diff --git a/lib/Time/Local.pm b/lib/Time/Local.pm
index 7a10d98ba7..8cb6a96f5f 100644
--- a/lib/Time/Local.pm
+++ b/lib/Time/Local.pm
@@ -5,17 +5,6 @@ use Carp;
@ISA = qw( Exporter );
@EXPORT = qw( timegm timelocal );
-@EXPORT_OK = qw( $no_range_check );
-
-sub import {
- my $package = shift;
- my @args;
- for (@_) {
- $no_range_check = 1, next if $_ eq 'no_range_check';
- push @args, $_;
- }
- Time::Local->export_to_level(1, $package, @args);
-}
# Set up constants
$SEC = 1;
@@ -151,21 +140,23 @@ This is consistent with the values returned from localtime() and gmtime().
Also worth noting is the ability to disable the range checking that
would normally occur on the input $sec, $min, $hours, $mday, and $mon
-values. You can do this by setting $Time::Local::no_range_check = 1,
-or by invoking the module with C<use Time::Local 'no_range_check'>.
-This enables you to abuse the terminology somewhat and gain the
-flexibilty to do things like:
+values. You can do this by localizing $Time::Local::no_range_check
+to 1.
- use Time::Local qw( no_range_check );
+ use Time::Local;
+
+ {
+ local $Time::Local::no_range_check = 1;
- # The 365th day of 1999
- print scalar localtime timelocal 0,0,0,365,0,99;
+ # The 365th day of 1999
+ print scalar localtime timelocal 0,0,0,365,0,99;
- # The twenty thousandth day since 1970
- print scalar localtime timelocal 0,0,0,20000,0,70;
+ # The twenty thousandth day since 1970
+ print scalar localtime timelocal 0,0,0,20000,0,70;
- # And even the 10,000,000th second since 1999!
- print scalar localtime timelocal 10000000,0,0,1,0,99;
+ # And even the 10,000,000th second since 1999!
+ print scalar localtime timelocal 10000000,0,0,1,0,99;
+ }
Your mileage may vary when trying this trick with minutes and hours,
and it doesn't work at all for months.