Support interval types
Hello! It doesn't seem like pog currently supports Postgres' interval type. There are workarounds for the time being, but it would be great to have this natively translate to a gleam/time/duration.Duration!
Oh yes, that would be lovely!
I was having a look at this and to me it seems like interval cannot be turned into a Duration. Quoting from the Duration's docs:
This type does not represent calendar periods such as “1 month” or “2 days”. Those periods will be different lengths of time depending on which month or day they apply to. For example, January is longer than February. A different type should be used for calendar periods.
But if you have a look at a Postgres interval that's exactly what we refer to as a calendar period:
Internally, interval values are stored as three integral fields: months, days, and microseconds. These fields are kept separate because the number of days in a month varies, while a day can have 23 or 25 hours if a daylight savings time transition is involved.
So in order for Pog to support this we'd need to think of how that is represented in Gleam with something different from a Duration
Ah! That's very interesting.
How does the interval type get represented in pgo?
This is its typespec, seems to be different from Postgres actual representation:
{interval, {int, int, int}, int, int}
% ^-- {hours, minutes, seconds}
% ^-- days, months
Sounds like we should open an issue with pgo to get it to return data faithful to the pg representation