CalendarGrid 1.0

I'm pleased to announce my first open source project, called CalendarGrid.

CalendarGrid lets you build output like a calendar, with padding days at the beginning and end of months. It sports a flexible data structure so you can format it any way you want. You can also provide a 'plugin' to each day to give it extra knowledge. For example, this code was originally created for a booking system, so each day knew whether it was booked or not.

Find out more in the API docs-grid.rubyforge.org/.

Installation

Install with gems - gem install calendar_grid

Download from the official home at RubyForge

Sample usage

require 'calendar_grid'

cal = CalendarGrid.build
puts "Calendar from #{cal.first.strftime("%D")} to #{cal.last.strftime("%D")}"

cal.years.each do |y|
  puts y.year
  y.months.each do |m|
    puts m.strftime("%B")
    s = m.weeks.collect do |w|
      w.collect { |day| "#{(day.proxy?) ? '* ' : day.strftime("%d")}" }.join(" ")
    end
    puts s
    puts
  end
end

Output

Calendar from 06/01/05 to 05/31/06
2005

June
*  *  01 02 03 04 05
06 07 08 09 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 *  *  * 

...

Thanks to Graham Arrowsmith for letting me build it, and then release it to the community.

  • July 5, 2005
  • Dealing with ruby

There is 1 comment

  1. About 13 hours later, Ben Bleything said...

    Wow, that looks awesome. I can't wait to spend some time with it tomorrow!