API Reference¶
Date objects¶
-
class
khayyam.
JalaliDate
(year=1, month=1, day=1, julian_day=None)[source]¶ Represent a day in Persian(Jalali) Calendar.
The first parameter can be an integer,
datetime.date
orkhayyam.JalaliDate
.You may create this object by passing julian_day parameter.
>>> from khayyam import JalaliDate >>> JalaliDate(julian_day=2445218) khayyam.JalaliDate(1361, 6, 15, Doshanbeh) >>> from datetime import date >>> JalaliDate(date(1982, 9, 6)) khayyam.JalaliDate(1361, 6, 15, Doshanbeh) >>> JalaliDate(1361, 6, 15) khayyam.JalaliDate(1361, 6, 15, Doshanbeh)
Parameters: - year (
int
|datetime.date
|khayyam.JalaliDate
) – jalali year - month (int) – month 1-12
- day (int) – day of month
- julian_day (int) – julian day
Returns: A
khayyam.JalaliDate
instance.Return type: -
__format__
(format_string)¶ Format codes referring to hours, minutes or seconds will see 0 values. For a complete list of formatting directives, see Formatting and Parsing directives.
Parameters: format_string – The format string. Returns: A string representing the date, controlled by an explicit format string Return type: unicode
-
__weakref__
¶ list of weak references to the object (if defined)
-
copy
()[source]¶ It’s equivalent to:
>>> source_date = JalaliDate(1394, 3, 24) >>> JalaliDate(source_date.year, source_date.month, source_date.day) khayyam.JalaliDate(1394, 3, 24, Yekshanbeh)
Returns: A Copy of the current instance. Return type: khayyam.JalaiDate
-
daysinmonth
¶ Total days in the current month.
Type: int
-
englishweekdaynameascii
()[source]¶ Return type: unicode Returns: The corresponding english weekday name in ASCII: [Saturday - Friday]
-
firstdayofyear
()[source]¶ As it’s name says: it’s referring to a
JalaliDate
representing the first day of current instance’s year.Returns: First day of corresponding year. Return type: JalaliDate
-
static
formatterfactory
(fmt)[source]¶ By default it will be return a
khayyam.formatting.JalaliDateFormatter
instance based on given format string.Parameters: fmt (str) – see: Formatting and Parsing directives Returns: Formatter object, based on the given format string. Return type: khayyam.formatting.BaseFormatter
-
classmethod
fromordinal
(ordinal)[source]¶ Where Farvardin 1 of year 1 has ordinal 1.
ValueError is raised unless 1 <= ordinal <= khayyam.jalaliDate(khayyam.MAXYEAR).toordinal().
Returns: The date corresponding to the proleptic Shamsi ordinal. Return type: khayyam.JalaiDate
-
classmethod
fromtimestamp
(timestamp)[source]¶ Such as is returned by
time.time()
. This may raiseValueError
, if the timestamp is out of the range of values supported by the platform C localtime() function. It’s common for this to be restricted to years from 1970 through 2038. Note that on non-POSIX systems that include leap seconds in their notion of a timestamp, leap seconds are ignored by fromtimestamp().Returns: Local date corresponding to the POSIX timestamp Return type: khayyam.JalaiDate
-
isleap
¶ True if the current instance is in a leap year.
Type: bool
-
isoformat
()[source]¶ Returns ISO formatted jalali date.:
>>> JalaliDate(1361, 12, 4).isoformat() == '1361-12-04' True
Return type: str Returns: A string representing the date in ISO 8601 format, ‘YYYY-MM-DD’.
-
isoweekday
()[source]¶ Return type: int Returns: The day of the week as an integer, where Saturday is 1 and Friday is 7.
-
localdateformat
()[source]¶ It’s equivalent to:
>>> print(JalaliDate(1361, 6, 15).strftime('%A %D %B %N')) دوشنبه ۱۵ شهریور ۱۳۶۱
For example:
>>> print(JalaliDate(1394, 5, 6).localdateformat()) سه شنبه ۶ مرداد ۱۳۹۴
Returns: Appropriate localized string representing a persian day Return type: unicode
-
max
= khayyam.JalaliDate(3178, 12, 29, Chaharshanbeh)¶ Represent the maximum year which supported by this class.
-
min
= khayyam.JalaliDate(1, 1, 1, Jomeh)¶ Represent the minimum year which supported by this class.
-
monthabbr
()[source]¶ Return type: unicode Returns: The corresponding persian month abbreviation: [فر, ار, خر, تی, مر, شه, مه, آب, آذ, دی, به, اس]
-
monthabbr_ascii
()[source]¶ Return type: unicode Returns: The corresponding persian month abbreviation in ASCII: [F, O , Kh … E].
-
monthname
()[source]¶ Return type: unicode Returns: The corresponding persian month name: [فروردین - اسفند]
-
monthnameascii
()[source]¶ Return type: unicode Returns: The corresponding persian month name in ASCII: [Farvardin - Esfand]
-
replace
(year=None, month=None, day=None)[source]¶ Replaces the given arguments on this instance, and return a new instance.
Parameters: - year –
- month –
- day –
Returns: A
khayyam.JalaliDate
with the same attributes, except for those attributes given new values by which keyword arguments are specified.
-
strftime
(format_string)[source]¶ Format codes referring to hours, minutes or seconds will see 0 values. For a complete list of formatting directives, see Formatting and Parsing directives.
Parameters: format_string – The format string. Returns: A string representing the date, controlled by an explicit format string Return type: unicode
-
classmethod
strptime
(date_string, fmt)[source]¶ This is opposite of the
khayyam.JalaliDate.strftime()
, and used to parse date strings into date object.ValueError is raised if the date_string and format can’t be parsed by time.strptime() or if it returns a value which isn’t a time tuple. For a complete list of formatting directives, see Formatting and Parsing directives.
Parameters: - date_string –
- fmt –
Returns: A
khayyam.JalaliDate
corresponding to date_string, parsed according to formatReturn type: khayyam.JalaiDate
-
timetuple
()[source]¶ It’s equivalent to:
>>> time.struct_time((d.year, d.month, d.day, d.hour, d.minute, d.second, d.weekday(), dayofyear, [-1|1|0])) time.struct_time(tm_year=2015, tm_mon=7, tm_mday=28, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=1, tm_yday=209, tm_isdst=-1)
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.
Returns: A time.struct_time
such as returned by time.localtime().Return type: time.struct_time
-
todate
()[source]¶ Calculates the corresponding day in the gregorian calendar. this is the main use case of this library.
Returns: Corresponding date in gregorian calendar. Return type: datetime.date
-
toordinal
()[source]¶ It’s equivalent to:
>>> d = JalaliDate(1361, 6, 15) >>> (d - JalaliDate(khayyam.MINYEAR)).days + 1 496899
Returns: The corresponding proleptic Shamsi ordinal days. Return type: int
-
weekday
()[source]¶ Return type: int Returns: The day of the week as an integer, where Saturday is 0 and Friday is 6.
-
weekdayabbr
()[source]¶ Returns: The corresponding persian weekday abbreviation: [ش ی د س چ پ ج] Return type: unicode
-
weekdayabbrascii
()[source]¶ Returns: The corresponding persian weekday abbreviation in ASCII: [Sh, Y, D, Se, Ch, P, J] Return type: unicode
-
weekdayname
()[source]¶ Returns: The corresponding persian weekday name: [شنبه - جمعه] Return type: unicode
- year (
Date & Time objects¶
-
class
khayyam.
JalaliDatetime
(year=1, month=1, day=1, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, julian_day=None)[source]¶ Inherited from
khayyam.JalaliDate
.Represent a moment in Persian(Jalali) Calendar.
The first parameter can be an integer,
datetime.date
,khayyam.JalaliDate
,datetime.datetime
orkhayyam.JalaliDatetime
.You may create this object by passing julian_day parameter.
Parameters: - year (
int
|datetime.date
|khayyam.JalaliDate
) – jalali year - month (int) – 1-12
- day (int) – 1-31
- hour (int) – 0-23
- minute (int) – 0-59
- second (int) – 0-59
- microsecond (int) – 0-999999
- tzinfo (
datetime.tzinfo
| callable) – Timezone info - julian_day (int) –
Returns: An object representing a moment persian calendar.
Return type: -
__repr__
()¶ Return the default
khayyam.JalaliDatetime
representation.>>> print(JalaliDatetime(1394, 3, 24, 10, 2, 3, 999999, tzinfo=TehranTimezone).__unicode__()) khayyam.JalaliDatetime(1394, 3, 24, 10, 2, 3, 999999, tzinfo=+03:30 dst:60, Yekshanbeh)
-
__unicode__
()[source]¶ Return the default
khayyam.JalaliDatetime
representation.>>> print(JalaliDatetime(1394, 3, 24, 10, 2, 3, 999999, tzinfo=TehranTimezone).__unicode__()) khayyam.JalaliDatetime(1394, 3, 24, 10, 2, 3, 999999, tzinfo=+03:30 dst:60, Yekshanbeh)
-
ampm
()[source]¶ Return type: str Returns: The ‘ق.ظ’ or ‘ب.ظ’ to determine ante meridiem and or post meridiem
-
ampmascii
()[source]¶ Return type: str Returns: The ‘AM’ or ‘PM’ to determine ante meridiem and or post meridiem
-
astimezone
(tz)[source]¶ Return a
khayyam.JalaliDatetime
object with newkhayyam.JalaliDatetime.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.tz must be an instance of a
datetime.tzinfo
subclass, and itsdatetime.tzinfo.utcoffset()
anddatetime.tzinfo.dst()
methods must not returnNone
. self must be aware (self.tzinfo must not be None, and self.utcoffset() must not return None).If self.tzinfo is tz, self.astimezone(tz) is equal to self: no adjustment of date or time data is performed. Else the result is local time in time zone tz, representing the same UTC time as self: after astz = dt.astimezone(tz), astz - astz.utcoffset() will usually have the same date and time data as dt - dt.utcoffset(). The discussion of class
datetime.tzinfo
explains the cases at Daylight Saving Time transition boundaries where this cannot be achieved (an issue only if tz models both standard and daylight time).If you merely want to attach a time zone object tz to a datetime dt without adjustment of date and time data, use dt.replace(tzinfo=tz). If you merely want to remove the time zone object from an aware datetime dt without conversion of date and time data, use dt.replace(tzinfo=None).
Note that the default
datetime.tzinfo.fromutc()
method can be overridden in adatetime.tzinfo
subclass to affect the result returned bykhayyam.JalaliDatetime.astimezone()
. Ignoring error cases,khayyam.JalaliDatetime.astimezone()
acts like:def astimezone(self, tz): # doctest: +SKIP if self.tzinfo is tz: return self if self.tzinfo: utc = self - self.utcoffset() else: utc = self return tz.fromutc(utc.replace(tzinfo=tz))
Parameters: tz – datetime.tzinfo
Return type: khayyam.JalaliDatetime
-
classmethod
combine
(date, _time)[source]¶ Return a new jalali datetime object whose date members are equal to the given date object’s, and whose _time and tzinfo members are equal to the given _time object’s. For any datetime object d, d == datetime.combine(d.date(), d.timetz()). If date is a datetime object, its _time and tzinfo members are ignored.
Parameters: - date –
khayyam.JalaliDate
the date object to combine. - _time –
datetime.time
the time object to combine.
Returns: the combined jalali date & time object.
Return type: - date –
-
copy
()[source]¶ It’s equivalent to:
>>> source_date = JalaliDatetime(1394, 3, 24, 10, 2, 3, 999999) >>> JalaliDatetime(source_date.year, source_date.month, source_date.day, source_date.hour, source_date.minute, source_date.second, source_date.microsecond) khayyam.JalaliDatetime(1394, 3, 24, 10, 2, 3, 999999, Yekshanbeh)
Returns: A Copy of the current instance. Return type: khayyam.JalaliDatetime
-
date
()[source]¶ Return date object with same year, month and day.
Return type: khayyam.JalaliDate
-
dst
()[source]¶ If
khayyam.JalaliDatetime.tzinfo()
isNone
, returnsNone
, else returns self.tzinfo.dst(self), and raises an exception if the latter doesn’t returnNone
, or adatetime.timedelta
object representing a whole number of minutes with magnitude less than one day.Return type: datetime.timedelta
-
classmethod
formatterfactory
(fmt)[source]¶ Creates the appropriate formatter for this type.
Parameters: fmt – str The format string Returns: The new formatter instance. Return type: khayyam.formatting.JalaliDatetimeFormatter
-
classmethod
fromordinal
(ordinal)[source]¶ Return the jalali datetime corresponding to the proleptic jalali ordinal, where Farvardin 1 of year 1 has ordinal 1. ValueError is raised unless 1 <= ordinal <= JalaliDatetime.max.toordinal(). The hour, minute, second and microsecond of the result are all 0, and tzinfo is None.
-
classmethod
fromtimestamp
(timestamp, tz=None)[source]¶ Creates a new
khayyam.JalaliDatetime
instance from the given posix timestamp.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.Else tz must be an instance of a class
datetime.tzinfo
subclass, and the timestamp is converted to tz’s time zone. In this case the result is equivalent to tz.fromutc(JalaliDatetime.utcfromtimestamp(timestamp).replace(tzinfo=tz)).This method may raise ValueError, if the timestamp is out of the range of values supported by the platform C localtime() or gmtime() functions. It’s common for this to be restricted to years in 1970 through 2038.
Note that on non-POSIX systems that include leap seconds in their notion of a timestamp, leap seconds are ignored by fromtimestamp(), and then it’s possible to have two timestamps differing by a second that yield identical datetime objects. See also
khayyam.JalaliDatetime.utcfromtimestamp
.>>> JalaliDatetime.fromtimestamp(1313132131.21232) khayyam.JalaliDatetime(1390, 5, 21, 11, 25, 31, 212320, Jomeh)
Parameters: - timestamp – float the posix timestamp, i.e 1014324234.23423423.
- tz –
datetime.tzinfo
The optional timezone to get local date & time from the given timestamp.
Returns: The local date and time corresponding to the POSIX timestamp, such as is returned by
time.time()
.Return type:
-
hour
¶ Getter: Returns the hour Type: int
-
hour12
()[source]¶ Return The hour value between 1-12. use
khayyam.JalaliDatetime.ampm()
orkhayyam.JalaliDatetime.ampmascii()
to determine ante meridiem and or post meridiemReturn type: int
-
isoformat
(sep=’T’)[source]¶ Return a string representing the date and time in ISO 8601 format, YYYY-MM-DDTHH:MM:SS.mmmmmm or, if microsecond is 0, YYYY-MM-DDTHH:MM:SS
If utcoffset() does not return
None
, a 6-character string is appended, giving the UTC offset in (signed) hours and minutes: YYYY-MM-DDTHH:MM:SS.mmmmmm+HH:MM or, if microsecond is 0 YYYY-MM-DDTHH:MM:SS+HH:MMParameters: sep – str The separator between date & time. Returns: The ISO formatted date & time. Return type: str
-
localdatetimeformat
()[source]¶ Return a string representing the date and time in preserved format: %A %d %B %Y %I:%M:%S %p.
>>> print(JalaliDatetime(1394, 3, 24, 10, 2, 3, 999999).localdatetimeformat()) یکشنبه 24 خرداد 1394 10:02:03 ق.ظ
Returns: The local formatted date & time string. Return type: str
-
localdatetimeformatascii
()[source]¶ Return a string representing the date and time in preserved format: %E %d %G %Y %I:%M:%S %t.
>>> print(JalaliDatetime(1394, 3, 24, 10, 2, 3, 999999).localdatetimeformatascii()) Yekshanbeh 24 Khordad 1394 10:02:03 AM
Returns: The local ascii formatted date & time string. Return type: str
-
localshortformat
()[source]¶ Return a string representing the date and time in preserved format: %a %d %b %y %H:%M.
>>> print(JalaliDatetime(1394, 3, 24, 10, 2, 3, 999999).localshortformat()) ی 24 خر 94 10:02
Returns: The local short formatted date & time string. Return type: str
-
localshortformatascii
()[source]¶ Return a string representing the date and time in preserved format: %e %d %g %y %H:%M.
>>> print(JalaliDatetime(1394, 3, 24, 10, 2, 3, 999999).localshortformatascii()) Y 24 Kh 94 10:02
Returns: The local short ascii formatted date & time string. Return type: str
-
localtimeformat
()[source]¶ Return a string representing the date and time in preserved format: %I:%M:%S %p.
>>> print(JalaliDatetime(1394, 3, 24, 10, 2, 3, 999999).localtimeformat()) 10:02:03 ق.ظ
Returns: The local formatted time string. Return type: str
-
max
= khayyam.JalaliDatetime(3178, 12, 29, 23, 59, 59, 999999, Chaharshanbeh)¶ Represent the last moment which supported by this class.
-
microsecond
¶ Getter: Returns the microsecond Type: int
-
min
= khayyam.JalaliDatetime(1, 1, 1, 0, 0, 0, 0, Jomeh)¶ Represent the earlier moment which supported by this class.
-
minute
¶ Getter: Returns the minute Type: int
-
classmethod
now
(tz=None)[source]¶ If optional argument tz is
None
or not specified, this is like today(), but, if possible, supplies more precision than can be gotten from going through atime.time()
timestamp (for example, this may be possible on platforms supplying the C gettimeofday() function).Else tz must be an instance of a
datetime.tzinfo
subclass, and the current date and time are converted to tz’s time zone. In this case the result is equivalent to tz.fromutc(JalaliDatetime.utcnow().replace(tzinfo=tz)). See alsokhayyam.JalaliDate.today()
andkhayyam.JalaliDatetime.utcnow()
.Parameters: tz – datetime.tzinfo
The optional timezone to get current local date & time.Returns: the current local date and time Return type: khayyam.JalaliDatetime
-
replace
(year=None, month=None, day=None, hour=None, minute=None, second=None, microsecond=None, tzinfo=None)[source]¶ Return a
khayyam.JalaliDatetime
instance with the same attributes, except for those attributes given new values by whichever keyword arguments are specified. Note that tzinfo=None can be specified to create a naive datetime from an aware datetime with no conversion of date and time data, without adjusting the date the and time based tzinfo.Parameters: - year – int
- month – int
- day – int
- hour – int
- minute – int
- second – int
- microsecond – int
- tzinfo –
datetime.tzinfo
Return type:
-
second
¶ Getter: Returns the second Type: int
-
classmethod
strptime
(date_string, fmt)[source]¶ Return a
khayyam.JalaliDatetime
corresponding to date_string, parsed according to format.ValueError is raised if the date_string and format can’t be parsed with
khayyam.formatting.JalaliDatetimeFormatter
instance returned bykhayyam.JalaliDatetime.formatterfactory()
method.Parameters: - date_string – str The representing date & time in specified format.
- fmt – str The format string.
Returns: Jalali datetime object.
Return type:
-
time
()[source]¶ Return time object with same hour, minute, second and microseconds. tzinfo is
None
. See also methodkhayyam.JalaliDatetime.timetz()
.Return type: datetime.time
-
timetz
()[source]¶ Return time object with same hour, minute, second, microsecond, and tzinfo attributes. See also method
khayyam.JalaliDatetime.time()
.Return type: datetime.time
-
todatetime
()[source]¶ Converts the current instance to the python builtins
datetime.datetime
instance.Returns: the new datetime.datetime
instance representing the current date and time in gregorian calendar.Return type: datetime.datetime
-
tzinfo
¶ Getter: Returns the timezone info Type: datetime.tzinfo
-
tzname
()[source]¶ If
khayyam.JalaliDatetime.tzinfo()
isNone
, returnsNone
, else returns self.tzinfo.tzname(self), raises an exception if the latter doesn’t return:py:obj:`None`or a string object.Return type: str
-
tznameformat
()[source]¶ If
khayyam.JalaliDatetime.tzinfo()
isNone
, returns empty string, else returns self.tzinfo.tzname(self), raises an exception if the latter doesn’t return:py:obj:`None`or a string object.Return type: str
-
classmethod
utcfromtimestamp
(timestamp)[source]¶ This may raise ValueError, if the timestamp is out of the range of values supported by the platform C gmtime() function. It’s common for this to be restricted to years in 1970 through 2038. See also
khayyam.JalaliDatetime.fromtimestamp()
.Returns: The UTC datetime corresponding to the POSIX timestamp, with tzinfo None. Return type: khayyam.JalaliDatetime
-
classmethod
utcnow
()[source]¶ This is like
khayyam.JalaliDatetime.now()
, but returns the current UTC date and time, as a naive datetime object.Returns: The current UTC date and time, with tzinfo None. Return type: khayyam.JalaliDatetime
-
utcoffset
()[source]¶ If
khayyam.JalaliDatetime.tzinfo()
isNone
, returnsNone
, else returns self.tzinfo.utcoffset(self), and raises an exception if the latter doesn’t returnNone
, or adatetime.timedelta
object representing a whole number of minutes with magnitude less than one day.Return type: datetime.timedelta
- year (
Formatting & Parsing¶
-
class
khayyam.formatting.
JalaliDateFormatter
(format_string, directive_db=None)[source]¶ Bases:
khayyam.formatting.formatters.BaseFormatter
Responsible to parse and formatting of a
khayyam.JalaliDate
instance.
-
class
khayyam.formatting.
JalaliDatetimeFormatter
(format_string, directive_db=None)[source]¶ Bases:
khayyam.formatting.formatters.JalaliDateFormatter
Responsible to parse and formatting of a
khayyam.JalaliDatetime
instance.
Directives¶
-
class
khayyam.formatting.directives.base.
CompositeDateDirective
(key, name, regex, format_string=None, **kw)[source]¶ Bases:
khayyam.formatting.directives.base.Directive
A chain of directives, Representing a date.
-
sub_formatter
¶ Returns: The underlying formatter. Return type: khayyam.JalaliDateFormatter
-
-
class
khayyam.formatting.directives.base.
CompositeDatetimeDirective
(key, name, regex, format_string=None, **kw)[source]¶ Bases:
khayyam.formatting.directives.base.CompositeDateDirective
A chain of directives, Representing a datetime.
-
class
khayyam.formatting.directives.base.
Directive
(key, name, regex, type_, formatter=None, post_parser=None)[source]¶ Bases:
object
Base class for all formatting directives.
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
khayyam.formatting.directives.ampm.
AmPmASCIIDirective
(key, name, regex)[source]¶ Bases:
khayyam.formatting.directives.ampm.BaseAmPmDirective
Responsible class for parse and formatting of ‘AM’ and ‘PM’ in ASCII format.
-
class
khayyam.formatting.directives.ampm.
AmPmDirective
(key, name, regex)[source]¶ Bases:
khayyam.formatting.directives.ampm.BaseAmPmDirective
Responsible class for parse and formatting of ‘AM’ and ‘PM’ in persian format.
-
class
khayyam.formatting.directives.ampm.
BaseAmPmDirective
(key, name, regex)[source]¶ Bases:
khayyam.formatting.directives.base.Directive
Base class for parse and formatting of ‘AM’ and ‘PM’.
-
class
khayyam.formatting.directives.day.
DayOfYearDirective
(key, name, regex, type_, formatter=None, post_parser=None)[source]¶ Bases:
khayyam.formatting.directives.base.Directive
Representing day of year.
-
class
khayyam.formatting.directives.day.
PersianDayDirective
(key, name, regex, zero_padding=False, zero_padding_length=2)[source]¶ Bases:
khayyam.formatting.directives.persian.PersianNumberDirective
Representing a day in persian calendar.
-
class
khayyam.formatting.directives.day.
PersianDayOfYearDirective
(key, name, regex, zero_padding=False, zero_padding_length=2)[source]¶ Bases:
khayyam.formatting.directives.persian.PersianNumberDirective
Representing day of year in persian.
-
class
khayyam.formatting.directives.month.
PersianMonthDirective
(key, name, regex, zero_padding=False, zero_padding_length=2)[source]¶ Bases:
khayyam.formatting.directives.persian.PersianNumberDirective
Representing a month in persian.
-
class
khayyam.formatting.directives.persian.
PersianNumberDirective
(key, name, regex, zero_padding=False, zero_padding_length=2)[source]¶ Bases:
khayyam.formatting.directives.base.Directive
Representing a number in persian form.
-
class
khayyam.formatting.directives.time.
PersianHour12Directive
(key, name, regex, zero_padding=False, zero_padding_length=2)[source]¶ Bases:
khayyam.formatting.directives.persian.PersianNumberDirective
Representing Hour12 format in persian form.
-
class
khayyam.formatting.directives.time.
PersianHour24Directive
(key, name, regex, zero_padding=False, zero_padding_length=2)[source]¶ Bases:
khayyam.formatting.directives.persian.PersianNumberDirective
Representing Hour24 format in persian form.
-
class
khayyam.formatting.directives.time.
PersianMicrosecondDirective
(key, name, regex, zero_padding=False, zero_padding_length=2)[source]¶ Bases:
khayyam.formatting.directives.persian.PersianNumberDirective
Representing Microsecond in persian form.
-
class
khayyam.formatting.directives.time.
PersianMinuteDirective
(key, name, regex, zero_padding=False, zero_padding_length=2)[source]¶ Bases:
khayyam.formatting.directives.persian.PersianNumberDirective
Representing minute in persian form.
-
class
khayyam.formatting.directives.time.
PersianSecondDirective
(key, name, regex, zero_padding=False, zero_padding_length=2)[source]¶ Bases:
khayyam.formatting.directives.persian.PersianNumberDirective
Representing second in persian form.
-
class
khayyam.formatting.directives.tz.
PersianUTCOffsetDirective
(key, name, regex, zero_padding=False, zero_padding_length=2)[source]¶ Bases:
khayyam.formatting.directives.persian.PersianNumberDirective
Representing offset from UTC in persian form. only for timezone-aware instances.
-
class
khayyam.formatting.directives.tz.
TimezoneNameDirective
(key, name, regex, type_, formatter=None, post_parser=None)[source]¶ Bases:
khayyam.formatting.directives.base.Directive
Representing the timezone name. only for timezone-aware instances.
-
class
khayyam.formatting.directives.tz.
UTCOffsetDirective
(key, name, regex, type_, formatter=None, post_parser=None)[source]¶ Bases:
khayyam.formatting.directives.base.Directive
Representing offset from UTC. only for timezone-aware instances.
-
class
khayyam.formatting.directives.year.
PersianShortYearDirective
(key, name, regex, zero_padding=False, zero_padding_length=2)[source]¶ Bases:
khayyam.formatting.directives.persian.PersianNumberDirective
Representing 2 digits year in persian form.
-
class
khayyam.formatting.directives.year.
PersianYearDirective
(key, name, regex, zero_padding=False, zero_padding_length=2)[source]¶ Bases:
khayyam.formatting.directives.persian.PersianNumberDirective
Representing year in persian form.
-
class
khayyam.formatting.directives.year.
ShortYearDirective
(key, name, regex, type_, formatter=None, post_parser=None)[source]¶ Bases:
khayyam.formatting.directives.base.Directive
Representing 2 digits year format.
Timezone objects¶
-
class
khayyam.
Timezone
(offset, dst_offset=None, dst_checker=None, name=None)[source]¶ Bases:
datetime.tzinfo
Constants¶
-
khayyam.constants.
FRIDAY
= 6¶ Representing the Friday weekday.
-
khayyam.constants.
MAXYEAR
= 3178¶ Maximum year supported by the library.
-
khayyam.constants.
MINYEAR
= 1¶ Minimum year supported by the library.
-
khayyam.constants.
MONDAY
= 2¶ Representing the Monday weekday.
-
khayyam.constants.
SATURDAY
= 0¶ Representing the Saturday weekday.
-
khayyam.constants.
SUNDAY
= 1¶ Representing the Sunday weekday.
-
khayyam.constants.
THURSDAY
= 5¶ Representing the Thursday weekday.
-
khayyam.constants.
TUESDAY
= 3¶ Representing the Tuesday weekday.
-
khayyam.constants.
WEDNESDAY
= 4¶ Representing the Wednesday weekday.