NaiveDateTime.convert
You're seeing just the function
convert
, go back to NaiveDateTime module for more information.
Specs
convert(Calendar.naive_datetime(), Calendar.calendar()) :: {:ok, t()} | {:error, :incompatible_calendars}
Converts the given naive_datetime
from one calendar to another.
If it is not possible to convert unambiguously between the calendars
(see Calendar.compatible_calendars?/2
), an {:error, :incompatible_calendars}
tuple
is returned.
Examples
Imagine someone implements Calendar.Holocene
, a calendar based on the
Gregorian calendar that adds exactly 10,000 years to the current Gregorian
year:
iex> NaiveDateTime.convert(~N[2000-01-01 13:30:15], Calendar.Holocene)
{:ok, %NaiveDateTime{calendar: Calendar.Holocene, year: 12000, month: 1, day: 1,
hour: 13, minute: 30, second: 15, microsecond: {0, 0}}}