Closed martinmaillard closed 6 years ago
Two reasons, first, it is the direct equivalent of the old Timex.Time
type (just an Erlang timestamp), where Time
is not (it can only be used to represent a 24 hour clock). The Timex.Time
API was replaced with Timex.Duration
, along with the new struct. However I have not yet added a complete Timex.Time
API to work with the new Time
type, mostly because there hasn't been much need beyond the one function pair to_12hour_clock/1
and to_24hour_clock/1
. Because of this, I felt that getting a Timex.Duration
type back would be far more useful, both for the above reasons, plus it allows non-pgsql databases to use time to represent intervals/durations as well.
In 3.0.3 I added Duration.to_time/1
, Duration.to_time!/1
, and Duration.from_time/1
for converting Duration
back and forth between Time
, so if you desire a Time
struct, it is easy to obtain one from a Duration
.
I'm open to changing this at some point, but I was mostly looking for a relatively one-to-one migration from the old timex to the new, without introducing too many changes.
Ok that makes sense. Thanks for the answer!
I think I would prefer to have two different ecto types: Timex.Ecto.Time and Timex.Ecto.Duration. But I can work with one ;)
I can see the advantage in having a Time
type as well, so it's on my TODO list :)
I was wondering: what made you chose
Timex.Duration
forTimex.Ecto.Time
fields instead of theTime
type from standard lib?