Introduction
Introduction Statistics Contact Development Disclaimer Help
tics2txt-tsv - ics2txt - convert icalendar .ics file to plain text
git clone git://bitreich.org/ics2txt git://hg6vgqziawt5s4dj.onion/ics2txt
Log
Files
Refs
Tags
README
---
tics2txt-tsv (1410B)
---
1 #!/usr/bin/awk -f
2
3 function isleap(year)
4 {
5 return (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)
6 }
7
8 function mdays(mon, year)
9 {
10 return (mon == 2) ? (28 + isleap(year)) : (30 + (mon + (mon > 7)…
11 }
12
13 function timegm(year, mon, mday, hour, min, sec)
14 {
15 while (--mon >= 1)
16 mday += mdays(mon, year)
17 while (--year >= 1970)
18 mday += 365 + isleap(year)
19 return (((((mday - 1) * 24) + hour) * 60) + min) * 60 + sec
20 }
21
22 function date_ical(str, offset,
23 year, mon, mday, hour, min)
24 {
25 year = substr(str, 1, 4)
26 mon = substr(str, 5, 2)
27 mday = substr(str, 7, 2)
28 hour = substr(str, 10, 2)
29 min = substr(str, 12, 2)
30 offset = (substr(str, 16, 1) == "Z" ? 0 : offset)
31 return timegm(year, mon, mday, hour, min, 0) - offset
32 }
33
34 BEGIN {
35 "date +%z" | getline offset_str
36 close("date +%z")
37 hour = substr($0, 4, 2)
38 min = substr($0, 6, 2)
39 tzoffset = substr(zone, 3, 1) hour * 3600 + min * 60
40
41 FS = "[:;]"
42 }
43
44 {
45 gsub("\r", ""); gsub("\t", "\\\\t")
46 gsub("^ *", ""); gsub(" *$", "")
47
48 if (match($0, "^ ")) {
49 event[type] = event[type] substr($0, 2, length($0) - 1)
50 } else {
51 type = $1
52 i = index($0, ":")
53 event[type] = substr($0, i + 1, length($0) - i)
54 }
55
56 if ($0 ~ /^END:VEVENT/)
57 printf("%d\t%d\t%s\t%s\t%s\t%s\n",
58 date_ical(event["DTSTART"], offset),
59 date_ical(event["DTEND"], offset),
60 event["CATEGORIES"],
61 event["LOCATION"],
62 event["SUMMARY"],
63 event["DESCRIPTION"])
64 }
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.