Authors:
Release Date: January 9, 2022
License: MIT License
To execute this implementation, ensure you have Python 3.x installed and follow these steps:
pip install -r requirements.txt
python Calendar.pyA Calendar is a system for organizing days for social, religious, commercial, or administrative purposes. This implementation provides a programmatic way to generate and display the monthly calendar for any given year and month in the Gregorian calendar system.
The calculation of the day of the week for any date can be performed using Zeller's congruence. The formula for the Gregorian calendar is:
where:
-
$h$ is the day of the week (0 = Saturday, 1 = Sunday, 2 = Monday, ..., 6 = Friday). -
$q$ is the day of the month. -
$m$ is the month (3 = March, 4 = April, \dots, 12 = December; January and February are counted as months 13 and 14 of the previous year). -
$K$ is the year of the century ($year \pmod{100}$ ). -
$J$ is the zero-based century ($\lfloor year/100 \rfloor$ ).
- Algorithmic Logic: The implementation uses the standard Python
calendarmodule, which leverages the Gregorian calendar's properties. It handles leap year calculations and the varying number of days in each month. - Leap Year Rule: A year is a leap year if it is divisible by 4, except for century years, which must be divisible by 400.
- Modulo Arithmetic: The algorithm relies heavily on modulo operations to determine offsets from a known reference date (e.g., January 1, 1 AD).
- Library Integration: Uses the built-in
calendar.month(year, month)function to generate a pre-formatted string representation of the calendar. - Form Formatting: Demonstrates how to handle console output for tabular data.
- Input Handling: Accepts year and month as integers to allow for historical or future date inspection.
| Amey's Birthday | Mega's Birthday |
|---|---|
![]() |
![]() |
flowchart TD
A[Input Year & Month] --> B[Validate Input]
B --> C[Calculate First Day]
C --> D[Determine Days in Month]
D --> E{Leap Year?}
E -->|Yes & Feb| F[28 → 29 Days]
E -->|No| G[Standard Days]
F --> H[Generate Grid]
G --> H
H --> I[Format Output]
I --> J[Display Calendar]


