Introducing Persian DateTime Converter: Convert Python Dates to Persian Dates
Introducing Persian DateTime Converter: Convert Python Dates to Persian Dates
I'm thrilled to announce the release of a new Python package: Persian DateTime Converter! 🎉 This package allows developers to easily convert Python's Gregorian datetime objects to Persian (Jalali) dates with high accuracy, all without relying on any external libraries. If you're working on a project that needs to support Persian dates, this package is a great addition to your Python toolkit! 🛠️
Why Persian DateTime Converter?
The Persian (Jalali) calendar is widely used in Iran and other Persian-speaking countries. However, native support for this calendar in Python is limited. The Persian DateTime Converter package fills this gap by providing a simple, dependency-free solution for converting Gregorian dates to Persian dates.
Key Features
- No Dependencies: A pure Python solution with zero dependencies.
- Accurate Conversions: Converts Python
datetimeobjects to Persian dates with high precision. - Leap Year Support: Correctly handles leap years for both Gregorian and Persian calendars.
- Easy to Use: Simple API for quick and easy integration into your projects.
Installation
You can easily install the Persian DateTime Converter package via pip:
pip install persian_datetime_converter
Getting Started
Once you have installed the package, you can start converting dates with just a few lines of code:
from persian_datetime_converter.converter import PersianDateConverter
import datetime
# Example datetime: 13th September 2024
dt = datetime.datetime(2024, 9, 13)
# Convert to Persian date
persian_date = PersianDateConverter.convert(dt)
print(f"Gregorian: {dt.year}-{dt.month}-{dt.day} -> Persian: {persian_date[0]}-{persian_date[1]}-{persian_date[2]}")
# Output: Gregorian: 2024-9-13 -> Persian: 1403-6-23
Examples
Here are some additional examples to showcase the functionality of the package:
Converting the Start of the Persian Year
dt = datetime.datetime(2023, 3, 21) # 21st March 2023 (Start of Persian year 1402)
persian_date = PersianDateConverter.convert(dt)
print(persian_date) # Output: (1402, 1, 1)
Checking Leap Years
print(PersianDateConverter.is_leap_gregorian(2024)) # Output: True
print(PersianDateConverter.is_leap_gregorian(2023)) # Output: False
Contributing
If you are interested in contributing to this project, please feel free to fork the repository on GitHub and submit a pull request. Your feedback, bug reports, and feature requests are also greatly appreciated!
GitHub and PyPI Links
- 🔗 GitHub Repository: github.com/yourusername/persian_datetime_converter
- 📦 PyPI: pypi.org/project/persian-datetime-converter
Contact
If you have any questions, feel free to contact me at bahmanymb@gmail.com. I am looking forward to your feedback and suggestions to improve this package! 😊
Conclusion
Thank you for checking out Persian DateTime Converter. I hope it proves to be a valuable tool for developers working with Persian dates in Python. Happy coding! 🚀
Comments
Post a Comment