hamyar_paygah.utils.date_utils

Utilities related to date and time.

Functions

convert_iso_datetime_to_persian_string(string_iso_datetime)

Convert an ISO-8601 datetime string to a Persian datetime string.

qdate_to_datetime(gregorian_date)

Convert a QDate to a datetime.datetime object.

gregorian_to_persian(gregorian_date)

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:

str

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:

datetime.datetime

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.datetime instance or None.

Returns:

A jdatetime.datetime representing the same moment in the Jalali calendar, or None if the input is None.

Raises:

TypeError – If the input is not None and not a datetime.datetime instance.

Return type:

jdatetime.datetime | None