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

t/date.t fails today (2016-02-29) [rt.cpan.org #112559] #33

Closed
atoomic opened this issue Jan 15, 2020 · 2 comments
Closed

t/date.t fails today (2016-02-29) [rt.cpan.org #112559] #33

atoomic opened this issue Jan 15, 2020 · 2 comments

Comments

@atoomic
Copy link
Owner

@atoomic atoomic commented Jan 15, 2020

Migrated from rt.cpan.org#112559 (status was 'open')

Requestors:

Attachments:

From srezic@cpan.org on 2016-02-29 07:38:41
:

Today (2016-02-29):

$ perl5.22.1 -Mblib t/date.t
...
not ok 61 # 1999 10:02:18 "GMT"
...

Fake yesterday's date:

$ perl5.22.1 -MTime::Fake=-1d -Mblib t/date.t
...
1999 10:02:18 "GMT"                             Sun Feb 28 10:02:18 1999 GMT
ok 61
...

Fake tomorrow's date:

$ perl5.22.1 -MTime::Fake=+1d -Mblib t/date.t
...
1999 10:02:18 "GMT"                             Mon Mar  1 10:02:18 1999 GMT
ok 61
...


From srezic@cpan.org on 2016-02-29 07:41:32
:

On 2016-02-29 02:38:41, SREZIC wrote:
> Today (2016-02-29):
> 
> $ perl5.22.1 -Mblib t/date.t
> ...
> not ok 61 # 1999 10:02:18 "GMT"
> ...
> 
> Fake yesterday's date:
> 
> $ perl5.22.1 -MTime::Fake=-1d -Mblib t/date.t
> ...
> 1999 10:02:18 "GMT"                             Sun Feb 28 10:02:18 1999 GMT
> ok 61
> ...
> 
> Fake tomorrow's date:
> 
> $ perl5.22.1 -MTime::Fake=+1d -Mblib t/date.t
> ...
> 1999 10:02:18 "GMT"                             Mon Mar  1 10:02:18 1999 GMT
> ok 61
> ...

... and this happens every leap day, it seems:

$ perl -MTime::Local=timelocal -e 'warn timelocal(0,0,12,29,2-1,2020)'
1582977600 at -e line 1.
$ perl5.22.1 -MTime::Fake=1582977600 -Mblib t/date.t
...
not ok 61 # 1999 10:02:18 "GMT"
...


From arc@cpan.org on 2016-02-29 13:49:42
:

On Mon Feb 29 02:41:32 2016, SREZIC wrote:
> ... and this happens every leap day, it seems:
> 
> $ perl -MTime::Local=timelocal -e 'warn timelocal(0,0,12,29,2-1,2020)'
> 1582977600 at -e line 1.
> $ perl5.22.1 -MTime::Fake=1582977600 -Mblib t/date.t
> ...
> not ok 61 # 1999 10:02:18 "GMT"
> ...

I think the test in question is incorrect. It's trying to parse the string as a date, filling in the month and day (but not the year) from today's date whenever it gets run, but setting the year to 1999. This will fail on every leap day, because no such date exists in 1999.

Picking any leap year as the year will make this pass; see the attached patch, which uses 2000.

Thanks.

-- 
Aaron Crane


@eserte
Copy link

@eserte eserte commented Feb 29, 2020

Today it's exactly four years later (2020-02-29), another leap day, and the test is again failing:

t/date.t ..... 
Failed 1/148 subtests 

atoomic pushed a commit that referenced this issue Mar 4, 2020
Fixes GH #33

This test tries to build a date from the hard-coded year 1999, and the month
and day of the date it gets run. This will always fail on February 29th.

Hard-coding a leap year instead of 1999 fixes the problem.

(cherry picked from commit f7165548fcc818214699fe499e14b61aa621d380)
Signed-off-by: Nicolas R <cpan@atoomic.org>
@atoomic
Copy link
Owner Author

@atoomic atoomic commented Mar 4, 2020

we will have to wait another four years... and a release but the fix is in :-)
thanks @arc

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

No branches or pull requests

2 participants