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

-001-12-31 is not a good way to represent a date #4436

Closed
p6rt opened this issue Jul 24, 2015 · 4 comments
Closed

-001-12-31 is not a good way to represent a date #4436

p6rt opened this issue Jul 24, 2015 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jul 24, 2015

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

Searchable as RT125681$

@p6rt
Copy link
Author

p6rt commented Jul 24, 2015

From @AlexDaniel

Code​:
say Date.new("0000-01-01").truncated-to('week');
say Date.new("0000-01-01").pred();
say Date.new("0000-01-01") - 10000;

Result​:
-001-12-27
-001-12-31
-028-08-15

It seems like ISO 8601 allows negative dates, but it should be -0001-12-31.

“by convention 1 BC is labelled +0000, 2 BC is labeled -0001, and so on.”
(from https://en.wikipedia.org/wiki/ISO_8601)

Similarly,
Code​:
say Date.new("9900-01-01") + 100000

Result​:
10173-10-16

it's OK, but “An expanded year representation [±*Y*YYYY] must have an
agreed-upon number of extra year digits beyond the four-digit minimum, and
it must be prefixed with a + or − sign”.
If I got that right, then it should be +10173-10-16

That being said, I think that the whole thing that is not within 0000-9999
boundary is bound to cause errors, even if Perl6 will ever get it right.
Most naive approaches to parse dates will split by '-' which will break
horribly if the date starts with - sign.

And even Date.new() does not allow to pass anything but yyyy-mm-dd.

@p6rt
Copy link
Author

p6rt commented Aug 26, 2015

From @coke

On Fri Jul 24 13​:01​:20 2015, alex.jakimenko@​gmail.com wrote​:

Code​:
say Date.new("0000-01-01").truncated-to('week');
say Date.new("0000-01-01").pred();
say Date.new("0000-01-01") - 10000;

Result​:
-001-12-27
-001-12-31
-028-08-15

It seems like ISO 8601 allows negative dates, but it should be -0001-12-31.

“by convention 1 BC is labelled +0000, 2 BC is labeled -0001, and so on.”
(from https://en.wikipedia.org/wiki/ISO_8601)

Similarly,
Code​:
say Date.new("9900-01-01") + 100000

Result​:
10173-10-16

it's OK, but “An expanded year representation [±*Y*YYYY] must have an
agreed-upon number of extra year digits beyond the four-digit minimum, and
it must be prefixed with a + or − sign”.
If I got that right, then it should be +10173-10-16

That being said, I think that the whole thing that is not within 0000-9999
boundary is bound to cause errors, even if Perl6 will ever get it right.
Most naive approaches to parse dates will split by '-' which will break
horribly if the date starts with - sign.

And even Date.new() does not allow to pass anything but yyyy-mm-dd.

rakudo has been updated to emit 4 digit years even for the negative years, and is emitting a + on the 5 digit year. passing tests added to t/spec/S32-temporal/Date.t , closing ticket.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Aug 26, 2015

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

@p6rt p6rt closed this as completed Aug 26, 2015
@p6rt
Copy link
Author

p6rt commented Aug 26, 2015

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

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

1 participant