circuithub / rel8

Hey! Hey! Can u rel8?
https://rel8.readthedocs.io
Other
150 stars 38 forks source link

Replace `CalendarDiffTime` with a more useful type, like `NominalDiffTime` #308

Open sir4ur0n opened 4 months ago

sir4ur0n commented 4 months ago

Currently Rel8.Expr.Time treats durations (SQL type interval) as CalendarDiffTime.

The problem is that this type is rather useless. E.g.:

This type's only vaguely useful destructors are its fields ctMonths and ctTime, unfortunately ctMonths representing a number of months, one cannot find the duration it amounts to. CalendarDiffTime {ctMonths = 1, ctTime = fromInteger 0} has a different meaning (hence, duration value, hence number of days) between January and February vs between February and March.

How about switching to a more useful type, e.g. NominalDiffTime? This type has many useful destructors, like Ord and Num instances (e.g. one can myNominalDiffTime / nominalDay to find the number of days).