Hello everyone.
I have a question about NaiveDateTime module from_iso8601/2
function.
This function will parse string datetimes like 2019-05-23 13:36:26.287939
to NaiveDateTime. The second argument is the calendar (which is set to Calendar.ISO by default).
Say i have a string datetime in another calendar like 1398-05-21 10:03:04
. If i call from_iso8601 it will first parse the string and then convert it from ISO to my calendar.
NaiveDateTime.from_iso8601("1398-01-23 23:50:07", Jalaali.Calendar)
{:ok,
%NaiveDateTime{
calendar: Jalaali.Calendar,
day: 4,
hour: 23,
microsecond: {0, 0},
minute: 50,
month: 11,
second: 7,
year: 776
}}
I think it should parse the string datetime and inject the calendar into the NaiveDateTime struct.
Expected
NaiveDateTime.from_iso8601("1398-01-23 23:50:07", Jalaali.Calendar)
{:ok,
%NaiveDateTime{
calendar: Jalaali.Calendar,
day: 31,
hour: 23,
microsecond: {0, 0},
minute: 50,
month: 1,
second: 7,
year: 1398
}}
Note that the DateTime
module has a DateTime.from_iso8601/2
function which will parse the DateTime and then injects the calendar module into the datetime.
In other words, DateTime.from_iso8601/2
works OK but NaiveDateTime.from_iso8601/2
is not. Is this a bug or naive datetime is always considered as ISO?
@josevalim can you please take a look?
Related: elixir-jalaali #10