test.lua

Fri, 29 Mar 2013 15:01:47 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 29 Mar 2013 15:01:47 +0000
changeset 3
c16d25785df1
parent 2
19d109c1625f
permissions
-rw-r--r--

Perform line unfolding

0
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 require "ical"
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 if arg[1] == "-v" then
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 require "serialization"
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 end
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5
2
19d109c1625f test.lua: Use arg[1] as input file if present
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
6 events = ical.load(io.open(arg[1] or "XSF.ics"):read("*a"))
0
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 if arg[1] == "-v" then
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 print(serialization.serialize(events))
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 end
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 for i, event in ipairs(events) do
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 if event.type == "VEVENT" then
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 print(event.when and os.date("!%c", event.when) or "Unknown", event.SUMMARY);
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 end
11a0cbd6c216 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 end

mercurial