Skip to main content

This module has the simple purpose of building html calendar tables with links and formatting. It is totally framework agnostic.

The module provides the htmlcalendar Python function that takes an starting date and a number of months for rendering the HTML Tables containing the specified months with formated cells and HTML links on day’s numbers.

Formatting is provided by passing a callback function as the classes parameters that takes the date and returns a list of CSS classes that are applied to the date’s cell.

Linking dates to URLs is also provided by a callback function passed as the links parameter that takes the date and returns a fully qualified HTML link if required or None if not.

For formatting the headers and the table you can use css classes in a list with the options th_classes and table_classes.

Attributes dictionary is added for allowing further customization of the calendar with the keyword attrs. Then, for ensuring safety on the building of the calendar the safe option is added to escape all the variables that are rendered building the calendar when it is disabled.

It also supports North American calendar with the option caltype putting its value to 1.

from flask import Flask
from datetime import date
from htmlcalendar import htmlcalendar

app = Flask("party")

def links(date):
        if date.weekday() == 5:
                return "https://github.com/llou/html-calendar"

def css_class(date):
        if date.weekday() == 5:
                return ["party"]

def attrs(date):
    return {"onclick": f"whatever({date.year}, {date.month}, {date.day})"}

@app.route("/")
def party_calendar():
        return htmlcalendar(date.today(), months=1, links=links, classes=css_class)

You can read the documentation at https://html-calendar.readthedocs.io/en/latest/

Release files for html-calendar 0.0.24

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for html-calendar 0.0.24
File Size Uploaded
html_calendar-0.0.24.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for html-calendar 0.0.24
File Interpreter ABI Platform
html_calendar-0.0.24-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 7.1 kB

Release files / html_calendar-0.0.24.tar.gz

Download URL html_calendar-0.0.24.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f26f21a0be6529983117018a0e5a85b37716e921bd680eea13e90be46ebeb0e4
BLAKE2b-256 checksum
How to use checksums
971227c9e6a31b9d494231fe69a4806a59e78c69413e7c07178bc826a27b603f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / html_calendar-0.0.24-py2.py3-none-any.whl

Download URL html_calendar-0.0.24-py2.py3-none-any.whl
Size 3.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
059f16681a9032ed1152339f4797d36fd55025cfe7311a27549c0032a1e6cd18
BLAKE2b-256 checksum
How to use checksums
bf598531555413f30ade2de0efe1a7a6a278823453166f908bfb3a662b3a81ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.0.24 This release

2 release files

0.0.13

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page