Skip to content

common/types: format Duration strings without float64 precision loss - #1672

Open
itzPranshul wants to merge 1 commit into
cel-expr:masterfrom
itzPranshul:pr3/fix-1651
Open

itzPranshul wants to merge 1 commit into
cel-expr:masterfrom
itzPranshul:pr3/fix-1651

Conversation

@itzPranshul

Copy link
Copy Markdown
Contributor

Closes #1651

Duration.ConvertToType(StringType), Duration.format, and ext/formatting_v2.go previously formatted durations via float64 (strconv.FormatFloat / strconv.AppendFloat), which loses fractional nanosecond digits for large durations (from ~100 days upward) and affects string(duration) and json.encode(duration).

This change formats durations directly from integer seconds and nanoseconds with trailing fractional zeros trimmed, and delegates DurationType formatting in ext/formatting_v2.go to ConvertToType(types.StringType).

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

Successfully merging this pull request may close these issues.

string(duration) and json.encode(duration) lose digits of the fractional seconds

1 participant