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

Truncate fractional time precision #127

Closed
moorereason opened this issue Jan 4, 2022 · 2 comments
Closed

Truncate fractional time precision #127

moorereason opened this issue Jan 4, 2022 · 2 comments
Assignees
Labels
bug Something isn't working implemented in v3 Fixes + features which were implemented in v3 release. TOML spec An issue relating to the library's TOML spec conformance.

Comments

@moorereason
Copy link

Environment

toml++ version and/or commit hash:
v3 f3bd22b

Compiler:
gcc 11.1.0

C++ standard mode:
c++20

Target arch:
linux x86_64

Library configuration overrides:
n/a

Relevant compilation flags:
meson build_tt --buildtype=release -Dbuild_tt_encoder=true -Dbuild_tt_decoder=true -Dgenerate_cmake_config=false

Describe the bug

Given the TOML document 0=00:00:00.0000000000, the parser returns an error:

$ echo "0=00:00:00.0000000000" | tt_decoder
Error while parsing time: fractional component exceeds maximum precision of 9
        (error occurred at line 1, column 21 of 'stdin')

Steps to reproduce

Compile toml-test decoder and use the following on the command-line:

echo "0=00:00:00.0000000000" | tt_decoder

Additional Information

This may be an implementation detail that should be ignored, but I'm reporting it anyway. I expected the precision to be truncated instead of seeing an error.

The TOML spec:

Millisecond precision is required. Further precision of fractional seconds is implementation-specific. If the value contains greater precision than the implementation can support, the additional precision must be truncated, not rounded.

If this is the desired behavior, let me know. Thanks

@moorereason moorereason added the bug Something isn't working label Jan 4, 2022
@marzer
Copy link
Owner

marzer commented Jan 4, 2022

Ah, thanks for letting me know. Indeed the parser should be behaving per the spec here, not issuing an error.

@marzer marzer added TOML spec An issue relating to the library's TOML spec conformance. v3 labels Jan 4, 2022
marzer added a commit that referenced this issue Jan 4, 2022
also:
- fixed extended-precision fractional times causing parse error instead of truncating per the spec (closes #127)
- fixed some non-spec vertical whitespace being accepted as line breaks (closes #128)
- added `format_flags::allow_unicode_strings`
@marzer
Copy link
Owner

marzer commented Jan 4, 2022

Fixed in v3 :)

@marzer marzer added implemented in v3 Fixes + features which were implemented in v3 release. and removed v3 labels Jan 4, 2022
@marzer marzer closed this as completed Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working implemented in v3 Fixes + features which were implemented in v3 release. TOML spec An issue relating to the library's TOML spec conformance.
Projects
None yet
Development

No branches or pull requests

2 participants