Fix Stammtisch generation

This commit is contained in:
Stefan Schlott 2013-08-28 10:01:35 +02:00
parent 63fc1722f5
commit b335a9a68c
2 changed files with 40 additions and 39 deletions

View file

@ -4,30 +4,31 @@
require 'date'
require 'yaml'
def event(day, dayoffset, location)
startDate = Time.new(day.year, day.month, day.day + dayoffset, 18, 0, 0, "+02:00")
{
'startdate' => startDate,
'duration' => '4h',
'location' => {
'location' => location
}
}
end
year=ARGV[0].to_i
result = { 'events' => [] }
for month in 1..12
date = DateTime.new(year,month,1,18,0,0)
date = Date.new(year,month,1)
firsttuesday = if (date.wday<=2)
date + (2-date.wday)
else
date + (9-date.wday)
end
result['events'] << {
'startdate' => firsttuesday.to_time,
'duration' => '4h',
'location' => {
'location' => 'zadu'
}
}
result['events'] << {
'startdate' => (firsttuesday+15).to_time,
'duration' => '4h',
'location' => {
'location' => 'shack'
}
}
result['events'] << event(firsttuesday, 0, 'zadu')
result['events'] << event(firsttuesday, 15, 'shack')
end
puts result.to_yaml