High level API for libjalali.
Note
Return a string representing the date, date(1392, 8, 2).ctime() == 'Thu Aba 02 00:00:00 1392'
Return the local date corresponding to the POSIX timestamp
Return a string representing the date in ISO 8601 format, YYYY-MM-DD. For example date(1392, 8, 2).isoformat() == 1392-08-02'
Return the day of the week as an integer, where Shanbeh is 1
Broken-down jalali time structure for this date
Return new date object where values for supplied keyword keywrod arguments reset: date(1392, 2, 8).replace(month=9) == date(1392, 9, 8)`
Return a string representing the date, controlled by an explicit format string. Format codes referring to hours, minutes or seconds will see 0 values.
Warning
libjalali’s jstrftime() defines custom formatting directives which might defined in your platform too but for other intentions. Check list of libjalali’s formatting directives.
Return a time.struct_time from this date. DST flag is -1
Return current local date
Return the day of the week as an integer, where Shanbeh is 0
Return a datetime object with new tzinfo attribute tz, adjusting the date and time data so the result is the same UTC time as self, but in tz‘s local time.
>>> from pytz import timezone
>>> d1 = datetime.now(timezone('Asia/Tehran'))
>>> d2 = d1.astimezone(timezone('Asia/Dubai'))
>>> d1 == d2, d1 - d2
(True, datetime.timedelta(0))
Make datetime from supplied date and time.
Parameters: |
|
---|
Return a string representing the date and time.
>>> datetime(1392, 9, 1, 12, 32, 14, 992).ctime()
'Jom Aza 01 12:32:14 1392'
If tzinfo is None, returns None, else returns self.tzinfo.dst(self), and raises an exception if the latter doesn’t return None, or a timedelta object.
Return the local date and time corresponding to the POSIX timestamp, such as is returned by time.time(). If optional argument tz is None or not specified, the timestamp is converted to the platform’s local date and time, and the returned datetime object is naive.
Return Gregorian python:datetime.datetime object corresponding to this datetime. Result will cached for future uses.
Return a string representing the date and time in ISO 8601 format, YYYY-MM-DDTHH:MM:SS.mmmmmm or, if :attr`:.microsecond is 0, YYYY-MM-DDTHH:MM:SS. The optional argument sep (default ‘T’) is a separator, placed between the date and time portions of the result.
>>> datetime(1392, 9, 1, 12, 32, 14, 992).isoformat(' ')
'1392-09-01 12:32:14.992'
Return the day of the week as an integer, where Shanbeh is 1
Broken-down jalali time structure for this date
Return the current local date and time. If a timezone provided, date and time will adjusted to that timezone.
Return a datetime with the same attributes, except for those attributes given new values by whichever keyword arguments are specified.
Return a string representing the date and time, controlled by an explicit format string.
Return a datetime corresponding to date_str, parsed according to format.
Return python:datetime.time object with same hour, minute, second and microsecond. tzinfo is None.
Return a time.struct_time from this date. The tm_isdst flag of the result is set according to the dst() method: tzinfo is None or dst() returns None, tm_isdst is set to -1; else if dst() returns a non-zero value, tm_isdst is set to 1; else tm_isdst is set to 0.
Return python:datetime.time object with same hour, minute, second, microsecond, and tzinfo attributes.
If tzinfo is None, returns None, else returns self.tzinfo.tzname(self), raises an exception if the latter doesn’t return None or a string object.
Return the UTC datetime corresponding to the POSIX timestamp, with tzinfo None.
Return the current UTC date and time, with tzinfo None. This is like now(), but returns the current UTC date and time, as a naive datetime object.
Timezone offset. If tzinfo is None, returns None, else returns self.tzinfo.utcoffset(self), and raises an exception if the latter doesn’t return None, or a datetime.timedelta object.
>>> from pytz import timezone,AmbiguousTimeError,NonExistentTimeError
>>> timezone('Asia/Tehran').utcoffset(datetime(1390, 1, 1, 10, 2))
datetime.timedelta(0, 12600)
>>> timezone('Asia/Tehran').utcoffset(datetime(1390, 6, 30, 22, 30))
datetime.timedelta(0, 16200)
>>> ambiguous = datetime(1392, 6, 30, 23, 30)
>>> try:
... timezone('Asia/Tehran').utcoffset(ambiguous)
... except AmbiguousTimeError:
... print "caught"
caught
>>> non_existent = datetime(1390, 1, 2, 0, 45)
>>> try:
... timezone('Asia/Tehran').utcoffset(non_existent)
... except NonExistentTimeError:
... print "caught"
caught
Return the day of the week as an integer, where Shanbeh is 0.
Alias for gregorian_from_jalali().
Alias for jalali_from_gregorian().
See datetime.now().
See datetime.utcnow().
Make Jalali datetime from Gregorian python:datetime.datetime or make Jalali date from Gregorian python:datetime.date.
>>> from datetime import datetime as _dtm, date as _dt
>>> jalali_from_gregorian(_dtm(2013, 11, 23, 23, 46, 0, 703498))
pyjalali.datetime.datetime(1392, 9, 2, 23, 46, 0, 703498)
>>> jalali_from_gregorian(_dtm(2013, 4, 13, 21, 10, 2, 292))
pyjalali.datetime.datetime(1392, 1, 24, 21, 10, 2, 292)
>>> jalali_from_gregorian(_dtm(2013, 3, 22, 0, 12))
pyjalali.datetime.datetime(1392, 1, 2, 0, 12, 0, 0)
>>> jalali_from_gregorian(_dt(2013, 3, 21))
pyjalali.datetime.date(1392, 1, 1)
Make Gregorian python:datetime.datetime from Jalali datetime or make Gregorian python:datetime.date from Jalali date.
>>> gregorian_from_jalali(datetime(1392, 9, 2, 23, 10, 2))
datetime.datetime(2013, 11, 23, 23, 10, 2)
>>> gregorian_from_jalali(datetime(1392, 6, 30, 22, 30))
datetime.datetime(2013, 9, 21, 22, 30)
>>> gregorian_from_jalali(date(1392, 6, 30))
datetime.date(2013, 9, 21)
Return datetime from provided timestamp ts.
Parameters: |
|
---|
libjalali custom functions.
Alter provided types.struct_jtm object’s fields tm_mon and tm_mday based on its tm_yday field. In case of failure raise ValueError exception if silent is not True.
Alter provided types.struct_jtm object’s fields tm_mon and tm_mday based on its tm_yday field. In case of failure raise ValueError exception if silent is not True.
Return number of seconds elapsed since UTC Epoch based on supplied types.struct_ab_jtm.
Return types.struct_ab_jtm from given timestamp.
Calculates Jalali date based on given number of days since UTC Epoch and return result as types.struct_jtm.
Return number of days passed since UTC Epoch based on given types.struct_jtm. In case of failure raise ValueError exception if silent is not True.
Fill given types.struct_jyinfo object’s fields with year information based on given year by types.struct_jyinfo.y.
Return number of days in provided month of year. Month number starts at zero
Return True if given year is leap year else False.
Updates given types.struct_jtm object’s fields based on its tm_year, tm_mon and tm_mday.
String formatting and deformatting
Return string representation of given time according to format.
Parameters: |
|
---|
Return types.struct_jtm from date_str according to format.
Parameters: |
|
---|
Time functions.
Functions jasctime, jctime, jgmtime and jlocaltime are forwarded to reentrant backends.
Return string representation of given time.
Parameters: |
|
---|
Return string representation of time from timestamp.
Parameters: |
|
---|
Return types.struct_jtm from timestamp expressed in UTC.
Make types.struct_jtm from timestamp according to local zone and dst settings.
Return timestamp from provided time.
:param pyjalali.types.struct_jtm jtm
Core C types for libjalali binding.
Make time.struct_time from broken-down jalali time structure
Time passed since UTC Epoch
Structure/Union member
Structure/Union member
Structure/Union member
Structure/Union member
Broken-down jalali date and time
New instance of this object
Structure/Union member
Structure/Union member
Structure/Union member
Structure/Union member
Structure/Union member
Structure/Union member
Structure/Union member
Structure/Union member
Structure/Union member
Structure/Union member
Structure/Union member
Year specific information
Structure/Union member
Structure/Union member
Structure/Union member
Structure/Union member
Structure/Union member
Structure/Union member
Structure/Union member
alias of LP_c_int