Skip to content

Conversation

@ranvis
Copy link
Contributor

@ranvis ranvis commented May 29, 2024

As mentioned by @kylekatarnls in #14332 (comment), php_date_initialize_from_ts_double() doesn't handle the fractional part of a double in the way users would expect.

var_dump(DateTime::createFromTimestamp(1599828571.235612)); // => ...235611

Also for example, 1.000_001 (1.000_000_99999999991773...) is transformed to @1.000000.

The updated code calculates the delta between the provided value and the next double value (in the case above, 1.000_001_00000000013978...), and if the delta is less than or equal to 0.5 microseconds, it uses the next value.
I think this solves the problem while keeping the original results on other cases.

CC: @marc-mabe

Use the next value of timestamp if the delta is less than or equal to
0.5 microseconds, to address numerical errors around exact microseconds.
@ranvis
Copy link
Contributor Author

ranvis commented May 31, 2024

Closing as per #14375.

@ranvis ranvis closed this May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant