hamyar_paygah.utils.text_utils¶
Utility functions related to text.
Functions¶
|
Convert a Jalali date string to a Gregorian datetime object. |
|
Convert Jalali date and time strings to a Gregorian datetime. |
|
Check whether a server address has a valid HTTP/HTTPS URL structure. |
Module Contents¶
- hamyar_paygah.utils.text_utils.convert_date_to_datetime(date_string)¶
Convert a Jalali date string to a Gregorian datetime object.
The input must be in the format
YYYY/MM/DD. IfNoneor an empty string is provided,Noneis returned.- Parameters:
date_string (str | None) – Jalali date string in
YYYY/MM/DDformat.- Returns:
A
datetime.datetimeobject representing the corresponding Gregorian date at midnight, orNoneif the input isNoneor empty.- Return type:
datetime.datetime | None
- hamyar_paygah.utils.text_utils.convert_date_and_time_to_datetime(date_string, time_string)¶
Convert Jalali date and time strings to a Gregorian datetime.
The date must be in
YYYY/MM/DDformat and the time must be inHH:MMformat. If either value isNoneor equals"-",Noneis returned.- Parameters:
- Returns:
A
datetime.datetimeobject representing the corresponding Gregorian date and time, orNoneif inputs are missing or marked as invalid.- Return type:
datetime.datetime | None
- hamyar_paygah.utils.text_utils.is_valid_server_address(server_address)¶
Check whether a server address has a valid HTTP/HTTPS URL structure.
The address must: - Be a non-empty string - Use the
httporhttpsscheme - Contain a network location component (host)This function validates only the structural format of the URL. It does not verify DNS resolution or server reachability.