thojanssens1
Why doesn't `Calendar.ISO.naive_datetime_from_iso_days/1` return a `NaiveDateTime` struct?
Why doesn’t Calendar.ISO.naive_datetime_from_iso_days/1 return a NaiveDateTime struct? Instead it returns a tuple containing the year, month, etc.
https://hexdocs.pm/elixir/Calendar.ISO.html#naive_datetime_from_iso_days/1
Marked As Solved
kip
I believe that any calendar function that is itself consumed in calendar implementations returns a tuple, not the struct. Since naive_datetime_from_iso_days/1 is called in Date, DateTime, and Date.Range is returns a tuple. I think this also reduces the chance of recursive compilation errors due to when a struct is available…
Also Liked
thojanssens1
I also asked the question on IRC and jose replied:
josevalim> it returns tuples because it is meant to be used by NaiveDateTime to build its own stuff
josevalim> if it returned NaiveDateTime, we would have cyclic dependencies, which i try to avoid







