A simple Ecto custom type for the Postgres tstzrange
type.
Based on: https://gist.github.com/felipegasparini/7c9a6fa0c2c463c17540b8e8544f16cf With the following differences:
- Don't use the now-deprecated
Ecto.Datetime
- Implement
tstzrange
instead oftsrange
- Use a tuple to represent a range
{start, finish}
rather than a list[start, finish]
FYI this stops working with ecto 3.0 and postgrex 0.14.0.
Here is a complete example of creating
tsrange
andtstzrange
columns with Ecto 3.0: https://github.com/jgautsch/ecto_time_ranges^that repo also shows examples of how to query for overlapping ranges.