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

DateTime methods .earlier and .later allow negative years, days, seconds but not months (.earlier(months => -1)) #4994

Closed
p6rt opened this issue Jan 5, 2016 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Jan 5, 2016

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

Searchable as RT127161$

@p6rt
Copy link
Author

p6rt commented Jan 5, 2016

From @AlexDaniel

These are not working​:

Code​:
say DateTime.new(‘2016-01-31T05​:00​:00Z’).earlier(months => -1)

Result​:
Month out of range. Is​: 0, should be in 1..12
  in block <unit> at /tmp/CfLpbWf_RV line 1

Code​:
say DateTime.new(‘2016-01-31T05​:00​:00Z’).later(months => -1)

Result​:
Month out of range. Is​: 0, should be in 1..12
  in block <unit> at /tmp/jdJBjXGCdA line 1

But all these do​:

Code​:
say DateTime.new(‘2016-01-31T05​:00​:00Z’).earlier(years => -1)
Result​:
2015-01-31T05​:00​:00Z

Code​:
DateTime.new(‘2016-01-31T05​:00​:00Z’).earlier(days => -1)
Result​:
2016-02-01T05​:00​:00Z

Code​:
DateTime.new(‘2016-01-31T05​:00​:00Z’).earlier(seconds => -1)
Result​:
2016-01-31T05​:00​:01Z

Code​:
say DateTime.new(‘2016-01-31T05​:00​:00Z’).later(seconds => -1)
Result​:
2016-01-31T04​:59​:59Z

Personally I think that negative values should be allowed (so
TIMTOWTDI-ish!).

@p6rt
Copy link
Author

p6rt commented Jan 5, 2016

From @lizmat

On 05 Jan 2016, at 02​:25, Alex Jakimenko (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Alex Jakimenko
# Please include the string​: [perl #​127161]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127161 >

These are not working​:

Code​:
say DateTime.new(‘2016-01-31T05​:00​:00Z’).earlier(months => -1)

Result​:
Month out of range. Is​: 0, should be in 1..12
in block <unit> at /tmp/CfLpbWf_RV line 1

Code​:
say DateTime.new(‘2016-01-31T05​:00​:00Z’).later(months => -1)

Result​:
Month out of range. Is​: 0, should be in 1..12
in block <unit> at /tmp/jdJBjXGCdA line 1

$ 6 'say DateTime.new(‘2016-01-31T05​:00​:00Z’).earlier(months => -1)'
2016-02-29T05​:00​:00Z
6 'say DateTime.new(‘2016-01-31T05​:00​:00Z’).later(months => -1)'
2015-12-31T05​:00​:00Z

Fixed with d80c728e257dbe17384c4 , test unfudged with 233d409 , can be closed.

Liz

@p6rt
Copy link
Author

p6rt commented Jan 5, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 9, 2016

From @usev6

On Tue Jan 05 03​:55​:57 2016, elizabeth wrote​:
[...]

Fixed with d80c728e257dbe17384c4 , test unfudged with 233d409 , can be
closed.

Thanks! I'm closing this ticket as 'resolved'.

@p6rt p6rt closed this as completed Jan 9, 2016
@p6rt
Copy link
Author

p6rt commented Jan 9, 2016

@usev6 - Status changed from 'open' to 'resolved'

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