hamyar_paygah.utils.date_utils¶
Utilities related to date and time.
Functions¶
|
Convert an ISO-8601 datetime string to a Persian datetime string. |
|
Convert a QDate to a datetime.datetime object. |
|
Convert a Gregorian datetime to a Jalali (Persian) datetime. |
Module Contents¶
- hamyar_paygah.utils.date_utils.convert_iso_datetime_to_persian_string(string_iso_datetime)¶
Convert an ISO-8601 datetime string to a Persian datetime string.
The input string must be in a format supported by
datetime.datetime.fromisoformat. Microseconds are removed before conversion.- Parameters:
string_iso_datetime (str) – A datetime string in ISO-8601 format.
- Returns:
A string representation of the corresponding Persian datetime without microseconds.
- Raises:
ValueError – If the input string is not a valid ISO-8601 datetime.
- Return type:
- hamyar_paygah.utils.date_utils.qdate_to_datetime(gregorian_date)¶
Convert a QDate to a datetime.datetime object.
The returned datetime has time set to 00:00:00.
- Parameters:
gregorian_date (PySide6.QtCore.QDate) – A valid QDate instance.
- Returns:
A datetime.datetime representing the same date.
- Return type:
- hamyar_paygah.utils.date_utils.gregorian_to_persian(gregorian_date)¶
Convert a Gregorian datetime to a Jalali (Persian) datetime.
- Parameters:
gregorian_date (datetime.datetime | None) – A Gregorian
datetime.datetimeinstance orNone.- Returns:
A
jdatetime.datetimerepresenting the same moment in the Jalali calendar, orNoneif the input isNone.- Raises:
TypeError – If the input is not
Noneand not adatetime.datetimeinstance.- Return type:
jdatetime.datetime | None