hamyar_paygah.utils.date_utils ============================== .. py:module:: hamyar_paygah.utils.date_utils .. autoapi-nested-parse:: Utilities related to date and time. Functions --------- .. autoapisummary:: hamyar_paygah.utils.date_utils.convert_iso_datetime_to_persian_string hamyar_paygah.utils.date_utils.qdate_to_datetime hamyar_paygah.utils.date_utils.gregorian_to_persian Module Contents --------------- .. py:function:: 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. :param string_iso_datetime: 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. .. py:function:: qdate_to_datetime(gregorian_date) Convert a QDate to a datetime.datetime object. The returned datetime has time set to 00:00:00. :param gregorian_date: A valid QDate instance. :returns: A datetime.datetime representing the same date. .. py:function:: gregorian_to_persian(gregorian_date) Convert a Gregorian datetime to a Jalali (Persian) datetime. :param gregorian_date: 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.