Calendar was broken 2
I still need to upgrade to the super fancy version of the calender that was posted as a patch on typo.leetsoft.com, but it was loosely based on the calender system running on my version of typo. Unfortuneatly somewhere in my modification I had forgotten to include the critical piece of code that read:
[""] * (self.class.civil(year,month,1).wday)Which needed to be prepended to the array of dates in the month to ensure the calender started on the right day of the week for each month. Perhaps sometime next week I will dissassemble the patch that followed mine since it doesn’t seem to work as a patch set anymore. It would be nice to have a calender with AJAXy goodness and all that nonsense.
If anyone is interested I based all of my calendar code from a snipet that appeared on comp.lang.ruby:
calendar.rbrequire 'date' require 'enumerator'require ‘date’
require ‘enumerator’class Date
def weekdays (1..dim).to_a end def cal_print banner = ABBR_DAYNAMES.map{|d| d[0..1]}.join(‘ ’) puts "#{MONTHNAMES[month]} #{year}".center(banner.size) puts banner wd = [‘ ’] * wday + weekdays wd.each_slice(7) do |slice| puts slice.map{|d| d.to_s.rjust(2)}.join(‘ ’) end end
def days_in_month
self.class.civil(year, month, -1).day
end
alias dim days_in_monthend
month = (ARGV[0] || Date.today.mon).to_i
year = (ARGV[1] || Date.today.year).to_iDate.civil(year, month).cal_print
Perhaps the above comment about the missing line makes more sense in that context. Also hopefully someone determines a way to use syntax to auto-hilight code in typo.
