code: def calendar(ctx, date, agenda, year):
      
      do_full_year = year
      today = ctx.obj['now'].date()
      db = ctx.obj['db']
      term = ctx.obj['term']
  
      date_info = cliutil.parse_date(date)
      if 'relative' in date_info:
          year = today.year
          month = today.month + date_info['relative']
      elif 'date_based' in date_info:
          year = date_info.get('year', today.year)
          month = date_info.get('month', today.month)
          if 'month' not in date_info and 'day' not in date_info:
              do_full_year = True
      else:
          raise click.UsageError('Unknown date format')
  
      if agenda is None:
          agenda = not do_full_year
  
      if do_full_year:
          first_month = 1
          num_months = 12
      else:
          first_month = month - 1
          num_months = 3
  
      calendar = get_calendar(db, year, first_month, num_months)
      cliutil.handle_raw_output(ctx, list(calendar.values()))
  
      render_calendar(term, calendar, today, agenda)
docs: Show a 3-month calendar of meetups.
  
      \b
      date: The date around which the calendar is centered. May be:
          - YYYY-MM-DD, YY-MM-DD, YYYY-MM or YY-MM (e.g. 2015-08)
          - MM (e.g. 08): the given month in the current year
          - pN (e.g. p1): N-th last month
          - +N (e.g. +2): N-th next month
          - Omitted: today
          - YYYY: Show the entire year, as with -y