Skip to content

[BUG] Precision issue using ts_format and ts_strftime in bloblang #258

@XU-Nuo

Description

@XU-Nuo

I have encountered a precision issue using ts_format in bloblang mapping.

Input

root.time = (1555234838050/1000).ts_format("2006-01-02T15:04:05.999-07:00", "UTC")

Expected output

{
    "time": "2019-04-14T09:40:38.050+00:00"
}

Actual output

{
    "time": "2019-04-14T09:40:38.049+00:00"
}

Version

4.53.0

The same problem occurs using ts_strftime(). I read that these two methods support nanosecond precision, so ms precision shouldn't be a problem.
PS: I currently use a dirty trick to fix this problem and avoiding heavily string operation at the same time (which is critical for my high frequency use case):

root.time = (1555234838050/1000+0.0004).ts_format("2006-01-02T15:04:05.999-07:00", "UTC")

But I guess this can't be 100% safe as trying to build a feature on a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions