Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/ical/deserialize_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ defmodule ICal.DeserializeTest do
%ICal{events: [event]} = ICal.from_ics(ics)

assert event == %Event{
dtstart: Timex.to_datetime({{2015, 12, 24}, {8, 30, 0}}),
dtend: Timex.to_datetime({{2015, 12, 24}, {8, 45, 0}}),
dtstart: ~U[2015-12-24 08:30:00Z],
dtend: ~U[2015-12-24 08:45:00Z],
summary:
"Going fishing at the lake that happens to be in the middle of fun street.",
description:
Expand Down Expand Up @@ -323,7 +323,7 @@ defmodule ICal.DeserializeTest do
test "Event with RECURRENCE-ID with TZID" do
ics = Helper.test_data("event_with_recurrence_id_tz")
%ICal{events: [event]} = ICal.from_ics(ics)
expected = Timex.Timezone.convert(~U[2020-09-17 18:30:00Z], "America/Toronto")
expected = DateTime.shift_zone!(~U[2020-09-17 18:30:00Z], "America/Toronto")
assert event.recurrence_id == expected
end

Expand Down
44 changes: 20 additions & 24 deletions test/ical/event_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule ICal.EventTest do
END:VEVENT
"""

%Event{dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}})}
%Event{dtstamp: ~U[2015-12-24 08:45:00Z]}
|> ICal.Serialize.Event.component()
|> assert_fully_contains(expected)
end
Expand All @@ -34,9 +34,9 @@ defmodule ICal.EventTest do
"""

%Event{
dtstart: Timex.to_date({2015, 12, 24}),
dtend: Timex.to_date({2015, 12, 24}),
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}})
dtstart: ~D[2015-12-24],
dtend: ~D[2015-12-24],
dtstamp: ~U[2015-12-24 08:45:00Z]
}
|> ICal.Serialize.Event.component()
|> assert_fully_contains(expected)
Expand All @@ -52,9 +52,9 @@ defmodule ICal.EventTest do
"""

%Event{
dtstart: Timex.to_datetime({{2015, 12, 24}, {8, 30, 00}}),
dtend: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}}),
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}})
dtstart: ~U[2015-12-24 08:30:00Z],
dtend: ~U[2015-12-24 08:45:00Z],
dtstamp: ~U[2015-12-24 08:45:00Z]
}
|> ICal.Serialize.Event.component()
|> assert_fully_contains(expected)
Expand All @@ -73,8 +73,8 @@ defmodule ICal.EventTest do

%ICal.Event{
summary: "Film with Amy and Adam",
dtstart: Timex.to_datetime({{2015, 12, 24}, {8, 30, 00}}),
dtend: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}}),
dtstart: ~U[2015-12-24 08:30:00Z],
dtend: ~U[2015-12-24 08:45:00Z],
description: "Let's go see Star Wars, and have fun."
}
|> ICal.Serialize.Event.component()
Expand All @@ -90,18 +90,14 @@ defmodule ICal.EventTest do
END:VEVENT
"""

dtstart =
{{2015, 12, 24}, {8, 30, 00}}
|> Timex.to_datetime("America/Chicago")
dtstart = DateTime.new!(~D[2015-12-24], ~T[08:30:00], "America/Chicago")

dtend =
{{2015, 12, 24}, {8, 45, 00}}
|> Timex.to_datetime("America/Chicago")
dtend = DateTime.new!(~D[2015-12-24], ~T[08:45:00], "America/Chicago")

%Event{
dtstart: dtstart,
dtend: dtend,
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}})
dtstamp: ~U[2015-12-24 08:45:00Z]
}
|> ICal.Serialize.Event.component()
|> assert_fully_contains(expected)
Expand All @@ -121,7 +117,7 @@ defmodule ICal.EventTest do
description:
"See this link http://example.com/pub" <>
"/calendars/jsmith/mytime.ics",
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}})
dtstamp: ~U[2015-12-24 08:45:00Z]
}
|> ICal.Serialize.Event.component()
|> assert_fully_contains(expected)
Expand All @@ -137,7 +133,7 @@ defmodule ICal.EventTest do

%Event{
url: "http://example.com/pub/calendars/jsmith/mytime.ics",
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}})
dtstamp: ~U[2015-12-24 08:45:00Z]
}
|> ICal.Serialize.Event.component()
|> assert_fully_contains(expected)
Expand All @@ -153,7 +149,7 @@ defmodule ICal.EventTest do

%Event{
uid: 815,
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}})
dtstamp: ~U[2015-12-24 08:45:00Z]
}
|> ICal.Serialize.Event.component()
|> assert_fully_contains(expected)
Expand All @@ -169,7 +165,7 @@ defmodule ICal.EventTest do

%Event{
uid: "0815",
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}})
dtstamp: ~U[2015-12-24 08:45:00Z]
}
|> ICal.Serialize.Event.component()
|> assert_fully_contains(expected)
Expand All @@ -185,7 +181,7 @@ defmodule ICal.EventTest do

%Event{
geo: {43.6978819, -79.3810277},
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}})
dtstamp: ~U[2015-12-24 08:45:00Z]
}
|> ICal.Serialize.Event.component()
|> assert_fully_contains(expected)
Expand All @@ -201,7 +197,7 @@ defmodule ICal.EventTest do

%Event{
categories: ["Fishing", "Nature", "Sport"],
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}})
dtstamp: ~U[2015-12-24 08:45:00Z]
}
|> ICal.Serialize.Event.component()
|> assert_fully_contains(expected)
Expand All @@ -217,7 +213,7 @@ defmodule ICal.EventTest do

%Event{
status: :tentative,
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}})
dtstamp: ~U[2015-12-24 08:45:00Z]
}
|> ICal.Serialize.Event.component()
|> assert_fully_contains(expected)
Expand All @@ -233,7 +229,7 @@ defmodule ICal.EventTest do

%Event{
class: :private,
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}})
dtstamp: ~U[2015-12-24 08:45:00Z]
}
|> ICal.Serialize.Event.component()
|> assert_fully_contains(expected)
Expand Down
4 changes: 2 additions & 2 deletions test/ical/value_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ defmodule ICal.ValueTest do
alias ICal.Serialize

test "value of a date" do
result = Serialize.value(Timex.to_date({2016, 1, 4}))
result = Serialize.value(~D[2016-01-04])
assert result == "20160104"
end

test "value of a datetime" do
result = Serialize.value(Timex.to_datetime({{2016, 1, 4}, {0, 42, 23}}))
result = Serialize.value(~U[2016-01-04 00:42:23Z])
assert result == "20160104T004223Z"
end

Expand Down
44 changes: 22 additions & 22 deletions test/ical_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ defmodule ICalTest do
end

test "ICal with custom tz alter dates" do
dtstamp = Timex.to_datetime({{2015, 12, 24}, {8, 0, 00}})
dtstamp = ~U[2015-12-24 08:00:00Z]

%ICal{events: [%ICal.Event{dtstamp: parsed_date}]} =
Helper.test_data("custom_calendar_tz") |> ICal.from_ics()
Expand Down Expand Up @@ -112,16 +112,16 @@ defmodule ICalTest do
events = [
%ICal.Event{
summary: "Film with Amy and Adam",
dtstart: Timex.to_datetime({{2015, 12, 24}, {8, 30, 00}}),
dtstamp: Timex.to_datetime({{2015, 12, 23}, {19, 00, 00}}),
dtend: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}}),
dtstart: ~U[2015-12-24 08:30:00Z],
dtstamp: ~U[2015-12-23 19:00:00Z],
dtend: ~U[2015-12-24 08:45:00Z],
description: "Let's go see Star Wars."
},
%ICal.Event{
summary: "Morning meeting",
dtstart: Timex.to_datetime({{2015, 12, 24}, {19, 00, 00}}),
dtstamp: Timex.to_datetime({{2015, 12, 24}, {15, 00, 00}}),
dtend: Timex.to_datetime({{2015, 12, 24}, {22, 30, 00}}),
dtstart: ~U[2015-12-24 19:00:00Z],
dtstamp: ~U[2015-12-24 15:00:00Z],
dtend: ~U[2015-12-24 22:30:00Z],
description: "A big long meeting with lots of details."
}
]
Expand Down Expand Up @@ -150,9 +150,9 @@ defmodule ICalTest do
events = [
%ICal.Event{
summary: "Film with Amy and Adam",
dtstart: Timex.to_datetime({{2015, 12, 24}, {8, 30, 00}}),
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 00, 00}}),
dtend: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}}),
dtstart: ~U[2015-12-24 08:30:00Z],
dtstamp: ~U[2015-12-24 08:00:00Z],
dtend: ~U[2015-12-24 08:45:00Z],
description: "Let's go see Star Wars, and have fun.",
location: "123 Fun Street, Toronto ON, Canada"
}
Expand Down Expand Up @@ -183,9 +183,9 @@ defmodule ICalTest do
events = [
%ICal.Event{
summary: "Film with Amy and Adam",
dtstart: Timex.to_datetime({{2015, 12, 24}, {8, 30, 00}}),
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 00, 00}}),
dtend: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}}),
dtstart: ~U[2015-12-24 08:30:00Z],
dtstamp: ~U[2015-12-24 08:00:00Z],
dtend: ~U[2015-12-24 08:45:00Z],
description: "Let's go see Star Wars, and have fun.",
location: "123 Fun Street, Toronto ON, Canada",
url: "http://example.com/tr3GE5"
Expand All @@ -201,8 +201,8 @@ defmodule ICalTest do
events = [
%ICal.Event{
exdates: [
Timex.Timezone.convert(~U[2020-09-16 18:30:00Z], "America/Toronto"),
Timex.Timezone.convert(~U[2020-09-17 18:30:00Z], "America/Toronto")
DateTime.shift_zone!(~U[2020-09-16 18:30:00Z], "America/Toronto"),
DateTime.shift_zone!(~U[2020-09-17 18:30:00Z], "America/Toronto")
]
}
]
Expand Down Expand Up @@ -253,7 +253,7 @@ defmodule ICalTest do
end

test "ICalender.to_ics/1 with RECURRENCE-ID with timezone" do
recurrence_id = Timex.Timezone.convert(~U[2020-09-17 18:30:00Z], "America/Toronto")
recurrence_id = DateTime.shift_zone!(~U[2020-09-17 18:30:00Z], "America/Toronto")

events = [
%ICal.Event{
Expand All @@ -274,9 +274,9 @@ defmodule ICalTest do
events = [
%ICal.Event{
summary: "Film with Amy and Adam",
dtstart: Timex.to_datetime({{2015, 12, 24}, {8, 30, 00}}),
dtstamp: Timex.to_datetime({{2015, 12, 24}, {8, 00, 00}}),
dtend: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}}),
dtstart: ~U[2015-12-24 08:30:00Z],
dtstamp: ~U[2015-12-24 08:00:00Z],
dtend: ~U[2015-12-24 08:45:00Z],
description: "Let's go see Star Wars, and have fun.",
location: "123 Fun Street, Toronto ON, Canada",
url: "http://www.example.com"
Expand All @@ -296,9 +296,9 @@ defmodule ICalTest do
events = [
%ICal.Event{
summary: "Film with Amy and Adam",
dtstart: Timex.to_datetime({{2015, 12, 24}, {8, 30, 00}}),
dtend: Timex.to_datetime({{2015, 12, 24}, {8, 45, 00}}),
dtstamp: Timex.to_datetime({{2017, 12, 24}, {8, 00, 00}}),
dtstart: ~U[2015-12-24 08:30:00Z],
dtend: ~U[2015-12-24 08:45:00Z],
dtstamp: ~U[2017-12-24 08:00:00Z],
description: "First line\nThis is a new line\n\nDouble newline",
location: "123 Fun Street, Toronto ON, Canada",
url: "http://www.example.com"
Expand Down
Loading
Loading