Sha256: 8dc15b7187fffbf7de57a892847ae03cb8d9628ee875e0626997d239ff8e18a4

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

SimpleCalendar::Calendar.class_eval do
  attr_reader :timezone

  def start_date_with_timezone
    @start_date ||= (get_option(:start_date) || params[param_name] || timezone.now).to_date
  end
  alias_method_chain :start_date, :timezone

  def default_td_classes_with_timezone
    ->(start_date, current_calendar_date) {
      today = timezone.now.to_date
      td_class = ["day"]
      td_class << "today"  if today == current_calendar_date
      td_class << "past"   if today > current_calendar_date
      td_class << "future" if today < current_calendar_date
      td_class << 'start-date'    if current_calendar_date.to_date == start_date.to_date
      td_class << "prev-month"    if start_date.month != current_calendar_date.month && current_calendar_date < start_date
      td_class << "next-month"    if start_date.month != current_calendar_date.month && current_calendar_date > start_date
      td_class << "current-month" if start_date.month == current_calendar_date.month
      td_class << "wday-#{current_calendar_date.wday.to_s}"
      td_class << "has-events" if events_for_date(current_calendar_date).any?

      { class: td_class.join(" ") }
    }
  end
  alias_method_chain :default_td_classes, :timezone
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
appt-0.0.1.beta.3 config/initializers/simple_calendar_patch.rb
appt-0.0.1.beta.2 config/initializers/simple_calendar_patch.rb