Add static calendar() method to jdatetime.date for displaying monthly calendar#177
Add static calendar() method to jdatetime.date for displaying monthly calendar#177Peyman20122 wants to merge 28 commits into
Conversation
feat: add static calender method to jdatetime.date class
The problem with the code was that I used unittest.main() but did not import unittest.
|
Hello, good day, dear engineer |
|
Hi @Peyman20122 Thanks for your work. Before looking into the PR, I want to mention that this module strives to provide interfaces similar to those provided by the standard library datetime provides. I only found a module named Calendar My suggestion is that you work on |
|
Hello dear engineer @slashmili Thank you for your support I told you the truth, maybe the user wants the calendar to be inside the jdatetime library, that's why I made the pull request I also wrote a repository for the calendar, the link to which you can see below, it has both the Jalali calendar and the calendar with the moon in Scorpio |
|
@Peyman20122 I'd rather follow the Unix philosophy, especially for such small libraries. One more piece of advice: there are many Shamsi date conversion libraries in Python. The reason jdatetime has gained traction is that it serves as a drop-in replacement for Python's standard datetime library. I'd suggest taking the same approach and releasing a small jcalendar library. |
Hello dear engineer
Summary
This PR adds a new static method
calendar()to thejdatetime.dateclass. It displays a monthly calendar (week-based table) for any given Shamsi (Jalali) year and month, similar to the Unixcalcommand or Python'scalendarmodule.Motivation
Currently,
jdatetimeprovides date conversion and formatting but lacks a built‑in way to visualize a whole month as a weekly grid. This feature is useful for many Persian applications (CLI tools, scheduling widgets, etc.) and reduces boilerplate code for users.Changes
@staticmethod calendar(year=None, month=None, locale=None)tojdatetime.date.yearandmonthare omitted, it shows the current month.Example usage
Output example (English)
Additional notes
· The weekday headers assume Saturday = 0 (week starts on Saturday), consistent with jdatetime.date.weekday().
· The method does not depend on external libraries (e.g., numpy, hijridate).
· I have tested the method with various inputs and locales.