NoMethod error for Time.year?

I have some code that works fine on my own system but the remote
server is crashing. I’m sort of confused this should be very basic
Ruby. My logs are telling me:

NoMethodError (undefined method year' for Time:Class): /app/controllers/promotions_controller.rb:24:incalendar’

I’m getting it from the following code:

def calendar

  # Get the current time.
  t =

  # Get the first day of the month.
  @start_date =, t.month, 1)

  # Get the last day of the month.
  # Calculate the last day of the month.
  next_month = t.month+1
  next_year = t.year
  if t.month == 12
     next_month = 1
     next_year +=  1

  # Assign the calculated time to a new date object.
  @end_date =, next_month, 1)-1

  # Grab the current promotions for the current time period.
  @promotion =
  @current_promotions = Promotion.current(@start_date,@end_date)


Does anyone have any ideas?