循环输入用于 Google 日历的 .Ics 格式文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'date';

start, days, summary = DateTime.new(2010,1,1), 76, '到';

puts %{
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-TIMEZONE:UTC
X-WR-CALDESC:
};


days.times {
puts %{
BEGIN:VEVENT
DTSTART;VALUE=DATE:#{start.strftime('%Y%m%d')}
DTEND;VALUE=DATE:#{start = start.next; start.strftime('%Y%m%d')}
SUMMARY:#{summary}
END:VEVENT
}

};

puts %{END:VCALENDAR}