Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time::Local should not croak on "out-of-range" days #464

Closed
p5pRT opened this issue Sep 1, 1999 · 3 comments
Closed

Time::Local should not croak on "out-of-range" days #464

p5pRT opened this issue Sep 1, 1999 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 1, 1999

Migrated from rt.perl.org#1305 (status was 'resolved')

Searchable as RT1305$

@p5pRT
Copy link
Author

p5pRT commented Sep 1, 1999

From allen@grumman.com

  $ perl -MTime​::Local -e 'print scalar localtime timelocal 0,0,0,280,0,99'
  Day '280' out of range 1..31 at -e line 1

It is quite convenient to be able to use timelocal to convert from "julian"
YYDDD format to others.

The warning serves no purpose anyway, since the following is not caught

  $ perl -MTime​::Local -e 'print scalar localtime timelocal 0,0,0,31,2,99'
  Wed Mar 31 00​:00​:00 1999

Ie, there is no 31st day in February.

Appended is the trivial patch against _60 in case the pumpking
agrees with me.

John.

$ diff -c Local.pm.orig Local.pm
*** Local.pm.orig Tue Jul 20 13​:18​:01 1999
--- Local.pm Wed Sep 1 13​:28​:49 1999
***************
*** 74,80 ****
  $year = $_[5];
  $month = $_[4];
  croak "Month '$month' out of range 0..11" if $month > 11 || $month < 0;
- croak "Day '$_[3]' out of range 1..31" if $_[3] > 31 || $_[3] < 1;
  croak "Hour '$_[2]' out of range 0..23" if $_[2] > 23 || $_[2] < 0;
  croak "Minute '$_[1]' out of range 0..59" if $_[1] > 59 || $_[1] < 0;
  croak "Second '$_[0]' out of range 0..59" if $_[0] > 59 || $_[0] < 0;
--- 74,79 ----

@p5pRT
Copy link
Author

p5pRT commented Sep 1, 1999

From [Unknown Contact. See original ticket]

On Wed, 1 Sep 1999, I, John L. Allen wrote​:

The warning serves no purpose anyway, since the following is not caught

$ perl -MTime​::Local -e 'print scalar localtime timelocal 0,0,0,31,2,99'
  ^
  should be 1
Wed Mar 31 00​:00​:00 1999

And this should have been
  Wed Mar 3 00​:00​:00 1999

Ie, there is no 31st day in February.

John.

@p5pRT
Copy link
Author

p5pRT commented Sep 1, 1999

From [Unknown Contact. See original ticket]

On Wed, Sep 01, 1999 at 01​:33​:39PM -0400, John L. Allen wrote​:

Can we please get rid of the useless day range check in Time​::Local?
Pleeease? I recall this being argued before.

Indeed, I argued it before. But I proposed something slightly more
radical​: get rid of *all* range checking. Checking the range of
each arguement is orthogonal to calculating a GMT and should be a
separate routine.

BTW, didn't Mike Stok or someone have an alternate Time​::Local
implementation that was less buggy than the current implementation?

$ perl -MTime​::Local -e 'print scalar localtime timelocal 0,0,0,280,0,99'
Day '280' out of range 1..31 at -e line 1

It is quite convenient to be able to use timelocal to convert from "julian"
YYDDD format to others.

Yep, that's what I use it for.

The warning serves no purpose anyway, since the following is not caught

$ perl -MTime​::Local -e 'print scalar localtime timelocal 0,0,0,31,2,99'
Wed Mar 31 00​:00​:00 1999

you mean

perl -MTime​::Local -e 'print scalar localtime timelocal 0,0,0,31,1,99'

(February is month number 1)

-Scott
--
Jonathan Scott Duff
duff@​cbi.tamucc.edu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant