Calendar v0.13.1 Calendar.NaiveDateTime.Interval
A NaiveDateTime.Interval
consists of a start and an end NaiveDateTime
.
Summary
Types
t :: %Calendar.NaiveDateTime.Interval{from: %Calendar.NaiveDateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}, to: %Calendar.NaiveDateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}}
Functions
Formats interval in ISO 8601 extended format.
Example:
# With a `NaiveDateTime.Interval`
iex> %Calendar.NaiveDateTime.Interval{from: {{2016, 2, 27}, {10, 0, 0}} |> NaiveDateTime.from_erl!, to: {{2016, 3, 1}, {11, 0, 0}} |> NaiveDateTime.from_erl!} |> Calendar.NaiveDateTime.Interval.iso8601
"2016-02-27T10:00:00/2016-03-01T11:00:00"
# Also works with a `DateTime.Interval`
iex> %Calendar.DateTime.Interval{from: {{2016, 2, 27}, {10, 0, 0}} |> DateTime.from_erl!("Etc/UTC"), to: {{2016, 3, 1}, {11, 0, 0}} |> DateTime.from_erl!("Etc/UTC")} |> Calendar.NaiveDateTime.Interval.iso8601
"2016-02-27T10:00:00/2016-03-01T11:00:00"
Formats interval in ISO 8601 basic format.
Example:
iex> %Calendar.NaiveDateTime.Interval{from: {{2016, 2, 27}, {10, 0, 0}}, to: {{2016, 3, 1}, {11, 0, 0}}} |> Calendar.NaiveDateTime.Interval.iso8601_basic
"20160227T100000/20160301T110000"
# Also works with a `DateTime.Interval`
iex> %Calendar.DateTime.Interval{from: {{2016, 2, 27}, {10, 0, 0}} |> DateTime.from_erl!("Etc/UTC"), to: {{2016, 3, 1}, {11, 0, 0}} |> DateTime.from_erl!("Etc/UTC")} |> Calendar.NaiveDateTime.Interval.iso8601_basic
"20160227T100000/20160301T110000"