# Calendar > TODO: now need to use calendar of our template, above is generic one not so nice, but logic for calendar is clear but looked at other example and used some AI to convert to something useful see https://www.creative-tim.com/twcomponents/component/full-calendar they use a javascript snipet we need todo it on server e.g. from datetime import datetime ```python from datetime import datetime class CalendarGenerator: def __init__(self): self.month_names = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ] self.day_names = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'] self.year = datetime.now().year def is_leap_year(self, year): return (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0) def days_of_month(self): february_days = 29 if self.is_leap_year(self.year) else 28 return [31, february_days, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def day_of_week(self, year, month): day_of_week = datetime(year, month + 1, 1).weekday() return (day_of_week + 1) % 7 # Adjust to start from Monday def generate_days(self): days = [] for month in range(12): month_days = [] for day in range(1, self.days_of_month()[month] + 1): if len(month_days) < self.day_of_week(self.year, month): month_days.append('') month_days.append(day) days.append(month_days) return days def get_calendar_data(self): return { "month_names": self.month_names, "day_names": self.day_names, "year": self.year, "days": self.generate_days() } ``` ## calendar html ```html

<

{{ year }}

>

{% for month, days in days %}

{{ month_names[loop.index0] }}

{% for day in day_names %}

{{ day }}

{% endfor %}
{% for day in days %}

{{ day }}

{% endfor %}
{% endfor %}
``` ```python @app.route('/') def calendar(): calendar_generator = CalendarGenerator() calendar_data = calendar_generator.get_calendar_data() return render_template('calendar.html', **calendar_data) ```