def jlocaltime(timestamp): """Make :class:`.types.struct_jtm` from `timestamp` according to local zone and dst settings. """ res = struct_jtm() _jlocaltime_r(byref(time_t(timestamp)), byref(res)) return res
def jalali_get_date(days): """Calculates Jalali date based on given number of days since UTC Epoch and return result as :class:`.types.struct_jtm`. """ res = struct_jtm() _jalali_get_date(days, byref(res)) return res
def __init__(self, year, month, day): if not 1 <= month <= 12: raise ValueError('month value out of range [1, 12]') if day > jalali_year_month_days(year, month - 1): raise ValueError('day is out of range for month') self.__jtm = struct_jtm() self.__jtm.tm_year = year self.__jtm.tm_mon = month - 1 self.__jtm.tm_mday = day
def jstrptime(format, date_str): """Return :class:`.types.struct_jtm` from date_str according to format. :param string format: format of string representation :param string date_str: string representation """ date = struct_jtm() res = c_char_p() res = _jstrptime(date_str, format, byref(date)) return date, res
def _normalized_date(year, mon, mday): """For internal testing only. For actual normalization call jalali_update or normalize_jtm. 0 <= mon < 12 1 <= mday < 32 """ jtm = struct_jtm() jtm.tm_year = year jtm.tm_mon = mon jtm.tm_mday = mday jalali_update(jtm) return jtm.tm_year, jtm.tm_mon, jtm.tm_mday
def jgmtime(timestamp): """Return :class:`.types.struct_jtm` from `timestamp` expressed in UTC. """ res = struct_jtm() _jgmtime_r(byref(time_t(timestamp)), byref(res)) return res