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.Str bad second rounding #4910

Open
p6rt opened this issue Dec 23, 2015 · 1 comment
Open

DateTime.Str bad second rounding #4910

p6rt opened this issue Dec 23, 2015 · 1 comment
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 23, 2015

Migrated from rt.perl.org#127005 (status was 'new')

Searchable as RT127005$

@p6rt
Copy link
Author

p6rt commented Dec 23, 2015

From zefram@fysh.org

Internally DateTime allows its seconds value to be any kind of numeric
value in the right range, but when producing Str output in ISO 8601
format it limits the displayed seconds value to integral microseconds.
It attempts to round accordingly, but it screws up by only rounding the
seconds value in isolation​:

DateTime.new(​:year(2000), :second(59.9999999)).Str
2000-01-01T00​:00​:60.000000Z

It produces invalid output like this whenever rounding up in the last
microsecond of a minute. (If there's a leap second, :second(60.9999999)
is rounded to "​:61.000000".) The rounding ought to instead wrap the
seconds value and be carried to the minutes value, and to the hours if
the minutes wrap, and so on. Or from another point of view, one should
round the DateTime value, and then express the rounded DateTime exactly,
rather than round the expression.

-zefram

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant