Foundation
Foundation copied to clipboard
PgInterval error
Data 'PT-11H-26M-27.454181S' is not an ISO8601 interval representation.
Php does not comply IS08601 at 100%
https://github.com/pomm-project/Foundation/blob/master/sources/tests/Unit/Converter/PgInterval.php#L24
Yes, it seems PHP is lacking the representation of negative intervals. Even though there is a invert
flag, it makes the PgInterval
to store the absolute value and adds a negative sign at the end. This does not make PHP able to support interval representations like 2 days - 2 hours
which Postgresql supports.
This is a PHP issue, not a Pomm issue. Maybe it is somehow interesting to find a solution to have a fallback in case of such issue.
Hello, I encounter this issue a lot in my use case :/ I understand the bug come from php, but do you have any idea of a workaround I could implement? Thank you <3
What can be done from our side, is to support any classes that inherits from DateInterval
. This way, you could implement your own DateInteval class that would feature negative date intervals.
I have this issue in few places. I do date_trunc('second', field)
to ensure there will be no floating point time. It's a dirty hack but until PHP implement it we can't do a lot more.