datetime¶
Public Attributes¶
- badidatetime.datetime.MINYEARint
Constant indicating the minimum year this API can represent.
- badidatetime.datetime.MAXYEARint
Constant indicating the maximum year this API can represent.
- badidatetime.datetime.BADI_IANAstr
Constant indicating the IANA zone Asia/Terhan
- badidatetime.datetime.BADI_COORDtuple
Constant indication the latitude, longitude, amd zone offset for Tehran, Iran.
- badidatetime.datetime.GMT_COORDtuple
Constant indicating the latitude, longitude, amd zone offset for Greenwich UK.
- badidatetime.datetime.LOCAL_COORDtuple
Constant indicating the latitude, longitude, amd zone offset for the local locale.
- badidatetime.datetime.UTCbadidatetime.datetime.timezone
Constant indicating the timezone object information for Greenwich UK.
- badidatetime.datetime.BADIbadidatetime.datetime.timezone
Constant indicating the timezone object information for Tehran, Iran.
- badidatetime.datetime.LOCALbadidatetime.datetime.timezone
Constant indicating the timezone object information for the local locale.
- badidatetime.datetime.MONTHNAMES: list
Constant indicating the Badí’ month names.
- badidatetime.datetime.MONTHNAMES_ABV: list
Constant indicating the abbreviated Badí’ month names.
- badidatetime.datetime.DAYNAMES: tuple
Constant indicating the Badí’ day names.
- badidatetime.datetime.DAYNAMES_ABV: tuple
Constant indicating the abbreviated Badí’ day names.
Module Functions¶
- badidatetime.datetime._cmp(x, y)[source]¶
Compare two items.
- Parameters:
x (object) – Item one.
y (object) – Item two.
- Returns:
If 0 then x == y, else if 1 then x > y else if -1 then x < y.
- badidatetime.datetime._divide_and_round(a: int, b: int) int[source]¶
Divide a by b and round result to the nearest integer.
When the ratio is exactly half-way between two integers, the even integer is returned.
- Parameters:
a (int) – numerator
b (int) – denominator
- Returns:
Resultant value.
- Return type:
int
- badidatetime.datetime._check_offset(name: str, offset: timedelta) None[source]¶
Check that the arguments are valid. If offset is None, returns None else offset is checked for being in range.
- Parameters:
name (str) – Name is the offset-producing method, utcoffset, badioffset, or dst.
offset (timedelta) – The timezone offset.
- Raises:
assert – If the name is not in a list of constants.
TypeError – If offset is not a timedelta instance.
ValueError – If offset not greater than -1 and less than 1.
- badidatetime.datetime._check_tzinfo_arg(tz: tzinfo) None[source]¶
Check that the tz argument is either None or a tzinfo subclass.
- Parameters:
tz (tzinfo) – A tzinfo instance.
- Raises:
TypeError – If tz is not `None or a tzinfo subclass.
- badidatetime.datetime._cmperror(x, y) None[source]¶
Test that x and y are the correct types to be compared.
- Parameters:
x – Item one.
y – Item two.
- Raises:
TypeError – Argument a and b cannot be compared.
- badidatetime.datetime._format_time(hh: int, mm: int, ss: int, us: int, timespec: str = 'auto') str[source]¶
Format time to a string.
- Parameters:
hh (int) – The hour.
mm (int) – The minute.
ss (int) – The second.
us (int) – The microsecond.
- Returns:
A formatted string.
- Return type:
str
- badidatetime.datetime._format_offset(off: timedelta) str[source]¶
Format an ISO offset.
- Parameters:
off (timedelta) – A timedelta instance.
- Returns:
A formatted ISO offset.
- Return type:
str
- Raises:
TypeError – If off is not None or a timedelta instance.
- badidatetime.datetime._check_tzname(name: str) None[source]¶
Check that the name argument is either None or a str.
- Parameters:
name (str) – The name of the timezone.
- Raises:
TypeError – If name is not None or a str.
Classes¶
- class badidatetime.datetime.TZWithCoords(lat: float, lon: float, zone: float = None, *, key: str = None)[source]¶
Bases:
timezoneCorrect Badí’ dates must have the latitude, longitude, and time zone. None of the publicly available packages can use coordinates, hence the need for this class.
- __firstlineno__ = 2830¶
- static __new__(cls, lat: float, lon: float, zone: float = None, *, key: str = None) object[source]¶
Constructor
- Parameters:
lat (float) – The latitude.
lon (float) – The longitude.
zone (float) – The time zone.
key (str) – The IANA key.
- Returns:
The instantiated object.
- Return type:
- __reduce__() tuple[source]¶
Gather the class data for pickling.
- Returns:
The class data.
- Return type:
tuple
- __setstate__(state: dict) None[source]¶
Set the pickled data on the class.
- Parameters:
state (dict) – Pickled state of a TZWithCoords class.
- __static_attributes__ = ('_coords', '_name', '_offset', 'key', 'lat', 'lon', 'zone')¶
- __str__() str[source]¶
Returns a string representation of the current TZWithCoords object.
- Returns:
String representation of the current TZWithCoords object.
- Return type:
str
- _coords¶
- _name¶
- _zi¶
- property coordinates: tuple¶
Returns the coordinates as a tuple.
- Returns:
The coordinates.
- Return type:
tuple
- dst(dt: datetime = None) timedelta[source]¶
Returns a timedelta set to 0 (default) for no dst (Daylight Savings Time) or set to 1 for dst.
- classmethod fromzoneinfo(zoneinfo, lat: float, lon: float, zone: float) object[source]¶
Converts a ZoneInfo object into a TZWithCoords object. Not all functionality of the ZoneInfo object is implemented in TZWithCoords.
- Parameters:
zoneinfo (ZoneInfo) – The ZoneInfo object.
lat (float) – The latitude.
lon (float) – The longitude.
zone (float) – The time zone.
- Returns:
A TZWithCoords object.
- Return type:
- key¶
- lat¶
- lon¶
- zone¶
- class badidatetime.datetime.date(a: int, b: int = None, c: int = None, d: int = None, e: int = None)[source]¶
Bases:
BahaiCalendarImplements the date object for the Badí’ datetime package.
- __firstlineno__ = 232¶
- __format__(fmt: str) str[source]¶
Returns the same as strftime above except if the strings length is zero then __str__ is returned.
- Parameters:
fmt (str) – The format string used for formatting the output.
- Returns:
A string representation of the format.
- Return type:
str
- static __new__(cls, a: int, b: int = None, c: int = None, d: int = None, e: int = None)[source]¶
Instantiate the class.
- Parameters:
cls (date) – The class object.
a (int) – Long form this value is the Kill-i-Shay and short form it’s the year. If b and c are None then a becomes the pickle value that is parsed to the remaining values below.
b (int) – Long form this value is the Váḥid and short form it’s the month.
c (int) – Long form this is the year and short form it’s the day.
d (int) – Long for this value is the month and in the short form it’s not used.
e (int) – Long form this value is the day and in the short form it’s not used.
- Returns:
The instantiated class.
- Return type:
- __radd__(other)¶
Add a date to a timedelta.
- __reduce__() tuple[source]¶
A tuple of the class name and current state.
- Returns:
The class name and current state.
- Return type:
tuple
- __repr__()[source]¶
Convert to formal a string, for repr().
- Returns:
A string representing the date.
- Return type:
str
Note
>>> d = date(181, 1, 1) >>> repr(d) 'datetime.date(181, 1, 1)'
- __setstate(bytes_str: bytes) None¶
Set the current state.
- Parameters:
bytes_str (bytes) – The bytes string.
- __static_attributes__ = ('__date', '__short', '_day', '_hashcode', '_kull_i_shay', '_month', '_vahid', '_year')¶
- __str__() str¶
Return a string representation of the date. In the case of a short form date the returned Badí’ date is in ISO format. There is no ISO standard for the long form Badí’ date.
- Returns:
A string representation of the short or long form Badí’ date.
- Return type:
str
- _cmp(other) int[source]¶
Returns an integer representation of >, ==, or < of two date instances.
- Parameters:
other (date) – The other date instance to compare to.
- Returns:
If 0 then x == y, else if 1 then x > y else if -1 then x < y, where x is the self instance and y is the other instance.
- Return type:
int
- _getstate() bytes[source]¶
Get the current state.
- Returns:
The state of the current self instance.
- Return type:
bytes
- _hashcode¶
- classmethod _is_pickle_data(a, b) bool[source]¶
Check if the incoming date is pickle data or actual date information.
- Parameters:
a (int, str, or bytes) – Pickle data, the Kull-i-Shay’, or year.
b (NoneType or int) – None, Váḥid, or month
- Returns:
A Boolean if a short or long Badí’ date derived from pickle data. A None can be returned if a and b are real date information.
- Return type:
bool or NoneType
- _replace_long(*, kull_i_shay: int = None, vahid: int = None, year: int = None, month: int = None, day: int = None, hour: int = None, minute: int = None, second: int = None, microsecond: int = None, tzinfo=True, fold: int = None) object[source]¶
Replace any of the kull_i_shay, vahid, year, month, or day values.
- Parameters:
kull_i_shay (int) – A value representing the Kull-i-Shay’.
vahid (int) – A value representing the Váḥid.
year (int) – A value representing the year.
month (int) – A value representing the month.
day (int) – A value representing the day.
hour (int) – A value representing the hour.
minute (int) – A value representing the minute.
second (int) – A value representing the second.
microsecond (int) – A value representing the microsecond.
tzinfo (tzinfo) – A tzinfo instance representing the timezone.
fold (int) – Either a 0 meaning not fold or a 1 indicating the date in in the fold.
- Returns:
The long form date instance with replaced items.
- Return type:
- _replace_short(*, year: int = None, month: int = None, day: int = None, hour: int = None, minute: int = None, second: int = None, microsecond: int = None, tzinfo: tzinfo = True, fold: int = None) object[source]¶
Replace any of the year, month, or day values.
- Parameters:
year (int) – A value representing the year.
month (int) – A value representing the month.
day (int) – A value representing the day.
hour (int) – A value representing the hour.
minute (int) – A value representing the minute.
second (int) – A value representing the second.
microsecond (int) – A value representing the microsecond.
tzinfo (tzinfo) – A tzinfo instance representing the timezone.
fold (int) – Either a 0 meaning not fold or a 1 indicating the date in in the fold.
- Returns:
The short form date instance with replaced items.
- Return type:
- _short_from_long_form(time: tuple = ()) tuple[source]¶
Convert the long form Badí’ date to a short form Badí’ date and add the time if it exists.
- Parameters:
time (tuple) – A tuple representing the time. This is used by the datetime class.
- Returns:
The short form date from a long for date with the possible time.
- Return type:
tuple
- _str_convertion() str[source]¶
Return a string representation of the date. In the case of a short form date the returned Badí’ date is in ISO format. There is no ISO standard for the long form Badí’ date.
- Returns:
A string representation of the short or long form Badí’ date.
- Return type:
str
- property b_date: tuple¶
Get the Badí’ date as a tuple.
- Returns:
The Badí’ date.
- Return type:
tuple
- ctime() str[source]¶
Return ctime() style string in the short form Badí’ date.
- Returns:
A string representing the weekday, month name, and year.
- Return type:
str
- property day: int¶
Get the day of the month where 1 - 19 represents the normal Badí’ month and 1 - 4 or 5 represents Ayyám-i-Há.
- Returns:
The value associated with the day of the month.
- Return type:
int
- classmethod fromisocalendar(year: int, week: int, day: int, *, short: bool = True) object[source]¶
Construct a date from the ISO year, week number and weekday.
This is the inverse of the date.isocalendar() function.
- Parameters:
year (int) – The Badí’ year.
week (int) – The number of the week in the year.
day (int) – Badí’ day in week.
short (bool) – If True (default) the short form date is returned else False the long form date is returned.
- Returns:
The date instance.
- Return type:
- classmethod fromisoformat(date_string: str, *, short: bool = True) object[source]¶
Construct a date from a string in ISO 8601 format. We only can convert from short form Badí’ dates.
- Parameters:
date_string (str) – A string representing the date.
short (bool) – If True (default) the short form date is returned else False the long form date is returned.
- Returns:
The date instance derived from the string representation.
- Return type:
- classmethod fromordinal(n: int, *, short: bool = True) object[source]¶
Construct a date from a proleptic Badí’ ordinal.
Bahá 1 of year 1 is day 1. Only the year, month and day are non-zero in the result.
- classmethod fromtimestamp(t: float, *, short: bool = True) object[source]¶
Construct a date from a POSIX timestamp–like time.time().
- property is_short: bool¶
Get True if the current instance represents a short form Badí’ date or False if a long form Badí’ date.
:return True if short form date or False is long form date. :rtype: bool
- isocalendar()[source]¶
Return a NamedTuple containing ISO year, week number, and weekday.
The first ISO week of the year is the (Jalál-Istiqlāl) week containing the year’s first Fiḍāl; everything else derives from that.
The first week is 1; Jalál is 1 … Istiqlāl is 7.
- Returns:
An ISO year, week, and day.
- Return type:
_IsoCalendarDate
Note
ISO calendar algorithm taken from http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm modified for the Badí’ Calendar.
- isoformat() str[source]¶
Return the date formatted according to ISO.
- Returns:
String of the year, month, and day.
- Return type:
str
- isoweekday()[source]¶
Return day of the week, where Jalál (Saturday) == 1 … Istiqlāl (Friday) == 7. This is the ISO standard.
- Returns:
The numerical (1 - 7) day-of-the-week.
- Return type:
int
- property kull_i_shay: int¶
Get the Kull-i-Shay’.
- Returns:
The value associated with the Kull-i-Shay’.
- Return type:
int
- longmax = badidatetime.date(4, 5, 2, 19, 19)¶
- longmin = badidatetime.date(-5, 18, 1, 1, 1)¶
- max = badidatetime.date(1161, 19, 19)¶
- min = badidatetime.date(-1842, 1, 1)¶
- property month: int¶
Get the month where 1 - 19 represents the normal Badí’ month and 0 represents Ayyám-i-Há.
- Returns:
The value associated with the Ayyám-i-Há.
- Return type:
int
- replace(kull_i_shay: int = None, vahid: int = None, year: int = None, month: int = None, day: int = None) object[source]¶
Return a new date with new values for the specified fields.
- Parameters:
kull_i_shay (int) – A value representing the Kull-i-Shay’.
vahid (int) – A value representing the Váḥid.
year (int) – A value representing the year.
month (int) – A value representing the month.
day (int) – A value representing the day.
- Returns:
A date instance with replaced items.
- Return type:
- resolution = datetime.timedelta(days=1)¶
- strftime(fmt: str) str[source]¶
Returns a string representing the date from a format string.
:param str fmt:The format string. :returns: A string representing the date. :rtype: str
Note
Example: ‘%d/%m/%Y’
- timetuple() tuple[source]¶
Return local time tuple compatible with time.localtime().
- Returns:
The short or long form date.
- Return type:
NamedTuple
- toordinal() int[source]¶
Return proleptic Badí’ ordinal for the year, month and day.
Bahá 1 of year -1842 is day 1. Only the year, month and day values contribute to the result. If this class provides the long form Badí’ date it is converted to the short form before processing.
- Returns:
The ordinal representing the year, month, and day.
- Return type:
int
- property vahid: int¶
Get the Váḥid.
- Returns:
The value associated with the Váḥid.
- Return type:
int
- weekday() int[source]¶
Return day of the week, where Jalál (Saturday) == 0 … Istiqlāl (Friday) == 6.
- Returns:
The numerical (0 - 6) day-of-the-week.
- Return type:
int
- property year: int¶
Get the year.
Note
This value has a different meaning depending on if the date instance represents a long or short form date.
- Returns:
The value associated with the year.
- Return type:
int
- class badidatetime.datetime.datetime(a: int, b: int = None, c: int = None, d: int = None, e: int = None, hour: float = 0, minute: float = 0, second: float = 0, microsecond: int = 0, tzinfo: tzinfo = None, *, fold: int = 0)[source]¶
Bases:
date- datetime(year, month, day[, hour[, minute[, second[,
microsecond[,tzinfo]]]]])
The year, month and day arguments are required. tzinfo may be None, or an instance of a tzinfo subclass. The remaining arguments may be ints.
- __firstlineno__ = 1585¶
- static __new__(cls, a: int, b: int = None, c: int = None, d: int = None, e: int = None, hour: float = 0, minute: float = 0, second: float = 0, microsecond: int = 0, tzinfo: tzinfo = None, *, fold: int = 0) object[source]¶
Check if there is pickle data. If so parse and create the object. If not pickle data create the instance from the incoming date data.
- Parameters:
a (int) – If pickle data this is the bytes string. If not pickle data a could be the Kull-i-Shay’ if a long form date or if a short form date a is the year.
b (int) – If pickle data this is the tzinfo instance. If not pickle data b could be the Váḥid if a long form date or if a short form date b is the month.
c (int) – If a long form date c is the year or if a short form date, c is the day.
d (int) – If a long form date d is the month, if a short form date d is None and not used.
e (int) – If a long form date e is the day, if a short form date e is None and not used.
hour (float) – The hour.
minute (float) – The minute.
second (float) – The second.
microsecond (int) – The microsecond.
tzinfo (tzinfo) – The time zone information.
fold (int) – If 0 there is no fold in time, this is the more common situation, however, if it is 1 there is a fold in time at the DST switch to standard time.
- Returns:
The instance of the datetime class.
- Return type:
- __radd__(other)¶
Add a datetime and a timedelta.
- __reduce__() tuple[source]¶
A tuple of the class name and current state using protocol 2.
- Returns:
The class name and current state.
- Return type:
tuple
- __reduce_ex__(protocol: int) tuple[source]¶
A tuple of the class name and current state.
- Parameters:
protocol (int) – The protocol used to derive the state.
- Returns:
The class name and current state.
- Return type:
tuple
- __repr__() str[source]¶
Convert to formal string, for repr().
- Returns:
A string representation of the datetime instance.
- Return type:
str
- __setstate(bytes_str, tzinfo) None¶
Set the current state.
- Parameters:
bytes_str (bytes) – The bytes string.
tzinfo (tzinfo) – A tzinfo instance.
- __static_attributes__ = ('__date', '__short', '__time', '_day', '_fold', '_hashcode', '_hour', '_kull_i_shay', '_microsecond', '_minute', '_month', '_second', '_tzinfo', '_vahid', '_year')¶
- __str__(sep='T') str¶
A representation of the datetime instance.
- Parameters:
sep (str) – The ISO date and time separator. The standard is to use T.
- Returns:
A representation of the datetime instance.
- Return type:
str
- _cmp(other, allow_mixed: bool = False) int[source]¶
Returns an integer representation of >, ==, or < of two date instances.
- Parameters:
other (date) – The other date instance to compare to.
allow_mixed (bool) – An integer representation of two date instances.
- Returns:
If 0 then x == y, else if 1 then x > y else if -1 then x < y, where x is the self instance and y is the other instance.
- Return type:
int
- _create_time(hour: float, minute: float, second: float, microsecond: int) None[source]¶
Create the time portion of the datetime instance.
- Parameters:
hour (float) – The hour of the dat.
minute (float) – The minute of the hour.
second (float) – The second of the minute.
microsecond (int) – The microsecond.
- _dt_str_conversion(sep='T') str[source]¶
A representation of the datetime instance.
- Parameters:
sep (str) – The ISO date and time separator. The standard is to use T.
- Returns:
A representation of the datetime instance.
- Return type:
str
- classmethod _fromtimestamp(t, tz, *, short=True)[source]¶
Construct a datetime from a POSIX timestamp (like time.time()).
Note
An IANA key and timezone information alone cannot be reliably mapped to geographic location. Without an internet connection, the local latitude and longitude cannot be looked up. Without the latitude and longitude the calendar will compute sunset for Badíʿ dates using the configured default coordinates (e.g., Tehran). This fallback will cause different local Badíʿ days than expected for other regions.
- Parameters:
t (float) – POSIX timestamp.
utc (bool) – If True then the result is relative to UTC time else if False it is relative to local time.
tz (tzinfo) – A tzinfo instance.
short (bool) – If True (default) the short form date is returned else False the long form date is returned.
- Returns:
A datetime instance set to the date derived from the POSIX timestamp.
- Return type:
- _getstate(protocol: int = 3) tuple[source]¶
Get the current state.
- Parameters:
protocol (int) – The pickle protocol to use defaults to 3.
- Returns:
The state of the current self instance.
- Return type:
tuple
- _hashcode¶
- _hour¶
- classmethod _is_pickle_data(a, b) int[source]¶
Check if the incoming date is pickle data or actual date information.
- Parameters:
a (int, str, or bytes) – Pickle data, the kull_i_shay, or year.
b (NoneType or int) – None, vahid, or month
- Returns:
A Boolean if a short or long Badí’ date derived from pickle data. A None can be returned if a and b are real date information.
- Return type:
bool or NoneType
- _local_timezone()[source]¶
Always return the local time offset in a timezone instance.
- Returns:
The local time zone.
- Return type:
- _microsecond¶
- _minute¶
- _mktime() float[source]¶
Return integer POSIX timestamp.
- Returns:
The POSIX timestamp.
- Return type:
float
- _second¶
- _timetuple(offset) tuple[source]¶
Return UTC or BADI time tuple compatible with time.gmtime().
- Returns:
The UTC time tuple.
- Return type:
NamedTuple
- astimezone(tz: <property object at 0x75357bc6a610> = None)[source]¶
Returns a datetime instance with the provided tzinfo instance attached.
- property b_date: tuple¶
Get the Badí’ date as a tuple.
- Returns:
The Badí’ date.
- Return type:
tuple
- property b_time: tuple¶
Get the time as a tuple.
- Returns:
The time.
- Return type:
tuple
- classmethod combine(date: date, time: time, tzinfo: <property object at 0x75357bc6a610> = True)[source]¶
Construct a datetime from a given date and a given time.
- ctime() str[source]¶
Return a ctime formatted string.
- Returns:
A string with weekday, month name, day, hour, minute, second, and year.
- Return type:
str
- date() date[source]¶
Return the date part of the datetime instance.
- Returns:
The date part of the datetime instance.
- Return type:
- dst() int[source]¶
Return 0 if DST is not in effect, or the DST offset (as timedelta positive eastward) if DST is in effect.
This is purely informational; the DST offset has already been added to the UTC offset returned by utcoffset() if applicable, so there’s no need to consult dst() unless you’re interested in displaying the DST info.
- Returns:
The value as described above.
- Return type:
int
- property fold: int¶
Get the time fold. This is in the Autumn when the time is set back from daylight savings time to standard time and the same hour is repeated.
- Returns:
The time fold.
- Return type:
int
- classmethod fromisoformat(date_string: str)[source]¶
Construct a datetime from a string in one of the ISO 8601 formats. This only works with short form dates.
- Parameters:
date_string (str) – An ISO formatted string.
- Returns:
A datetime instance.
- Return type:
- classmethod fromtimestamp(t: float, tz: <property object at 0x75357bc6a610> = None, *, short: bool = True)[source]¶
Construct a datetime from a POSIX timestamp representing local time (like time.time()).
- property hour: float¶
Get the hour.
- Returns:
The hour.
- Return type:
float
- property is_short: bool¶
Get True if the current instance represents a short form Badí’ date or False if a long form Badí’ date.
:return True if short form date or False is long form date. :rtype: bool
- isoformat(sep: str = 'T', timespec: str = 'auto') str[source]¶
Return the time formatted according to ISO.
The full format looks like ‘YYYY-MM-DDTHH:MM:SS.mmmmmm’. By default, the fractional part is omitted if self.microsecond == 0.
If self.tzinfo is not None, the UTC offset is also attached, giving a full format of ‘YYYY-MM-DDTHH:MM:SS.mmmmmm+HH:MM’.
Optional argument sep specifies the separator between date and time, default ‘T’.
The optional argument timespec specifies the number of additional terms of the time to include. Valid options are ‘auto’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’ and ‘microseconds’.
- Parameters:
sep (str) – The ISO date and time separator. The standard is to use T.
timespec (str) – A special string as stated above that will append additional data to the string.
- Returns:
An ISO formatted string.
- Return type:
str
- max = badidatetime.datetime(1161, 19, 19, None, None, 0, 0)¶
- property microsecond: int¶
Get the microsecond.
- Returns:
The microsecond.
- Return type:
int
- min = badidatetime.datetime(-1842, 1, 1, None, None, 0, 0)¶
- property minute: float¶
Get the minute.
- Returns:
The minute.
- Return type:
float
- classmethod now(tz: <property object at 0x75357bc6a610> = None, short: bool = True)[source]¶
Construct a datetime from time.time() and optional time zone info.
- replace(kull_i_shay: int = None, vahid: int = None, year: int = None, month: int = None, day: int = None, hour: float = None, minute: float = None, second: float = None, microsecond: int = None, tzinfo: <property object at 0x75357bc6a610> = True, *, fold: int = None)[source]¶
Return a new datetime with new values for the specified fields.
- Parameters:
kull_i_shay (int) – The Kull-i-Shay’.
vahid (int) – The Váḥid.
year (int) – The year.
month (int) – The month.
day (int) – The day.
hour (float) – The hour.
minute (float) – The minute.
second (float) – The second.
microsecond (int) – The microsecond.
tzinfo (tzinfo) – A tzinfo instance.
fold (int) – The time fold.
- Returns:
The updated datetime instance.
- Return type:
- resolution = datetime.timedelta(microseconds=1)¶
- property second: float¶
Get the second.
- Returns:
The second.
- Return type:
float
- classmethod strptime(date_string: str, format: str) str[source]¶
String, format -> new datetime parsed from a string (like time.strptime()).
- Parameters:
date_string (str) – A string representing the date.
format (str) – A format string
- Returns:
A date and time string representing the format string.
- Return type:
str
- time()[source]¶
Return the time part, with tzinfo None of the datetime instance.
- Returns:
The time part of the datetime instance.
- Return type:
- timestamp() float[source]¶
Return POSIX timestamp for the current datetime instance.
- Returns:
The POSIX timestamp.
- Return type:
float
- timetuple()[source]¶
Return local time tuple compatible with time.localtime().
- Returns:
A tuple of the date and time values.
- Return type:
NamedTuple
- timetz() time[source]¶
Return the time part, with same tzinfo of the datetime instance.
- Returns:
The time part of the datetime instance.
- Return type:
- property tzinfo: tzinfo¶
Get the timezone info instance.
- Returns:
The timezone info instance.
- Return type:
- tzname() str[source]¶
Return the timezone name.
Note that the name is 100% informational – there’s no requirement that it mean anything in particular. For example, ‘GMT’, ‘UTC’, ‘-500’, ‘-5:00’, ‘EDT’, ‘US/Eastern’, ‘America/New_York’ are all valid replies.
- Returns:
The name of the time zone or None if not tzinfo instance was found.
- Return type:
str
- class badidatetime.datetime.time(hour: float = 0, minute: float = 0, second: float = 0, microsecond: int = 0, tzinfo: tzinfo = None, *, fold: int = 0)[source]¶
Bases:
objectTime with time zone.
Constructors:
__new__()
Operators:
__repr__, __str__ __eq__, __le__, __lt__, __ge__, __gt__, __hash__
Methods:
strftime() isoformat() utcoffset() tzname() dst()
Properties (readonly): hour, minute, second, microsecond, tzinfo, fold
- __firstlineno__ = 1062¶
- __format__(fmt: str) str[source]¶
More or less the same as strftime, however, if fmt is 0 length, then return str(self).
- Parameters:
fmt (str) – The format string.
- Returns:
A string formatted as pre the fmt argument.
- Return type:
str
- static __new__(cls, hour: float = 0, minute: float = 0, second: float = 0, microsecond: int = 0, tzinfo: tzinfo = None, *, fold: int = 0) object[source]¶
Constructor.
- Parameters:
hour (float) – Hours (required)
minute (float) – Minutes (required)
second (float) – Seconds (default to zero)
microsecond (int) – Microseconds (default to zero)
tzinfo (tzinfo) – Timezone information (default to None)
fold (int) – (keyword only, default to zero)
- Returns:
The self instance.
- Return type:
- __reduce__() tuple[source]¶
Get the class name and current state using protocol 2.
- Returns:
The class name and current state.
- Return type:
tuple
- __reduce_ex__(protocol: int) tuple[source]¶
Get the class name and the default protocol state.
- Parameters:
protocol (int) – The protocol used to derive the state.
- Returns:
The class name and current state.
- Return type:
tuple
- __repr__() str[source]¶
Convert to formal string, for repr().
- Returns:
A string representing the current self instance.
- Return type:
str
- __setstate(string: str, tzinfo: <property object at 0x75357bc6a430>) None¶
Set the current state of the self instance.
- Parameters:
string (str) – A byte string.
tzinfo (tzinfo,) – Time zone information.
- Raises:
TypeError – If the tzinfo argument is not a tzinfo instance.
- __static_attributes__ = ('_fold', '_hashcode', '_hour', '_microsecond', '_minute', '_second', '_tzinfo')¶
- __str__(timespec: str = 'auto') str¶
Return the time formatted according to ISO.
The full format is ‘HH:MM:SS.mmmmmm+zz:zz’. By default, the fractional part is omitted if self.microsecond == 0.
The optional argument timespec specifies the number of additional terms of the time to include. Valid options are auto, hours, minutes, seconds, milliseconds and microseconds.
- Parameters:
timespec (str) – The specification is either auto (default) or milliseconds.
- Returns:
An ISO formatted string.
- Return type:
str
- _cmp(other, allow_mixed=False)[source]¶
A low level time compare method.
- Parameters:
other (time) – Another time instance.
allow_mixed (bool) – True if a naive and aware time objects are allowed else if False they are not allowed. Only the __eq__ method sets this to True.
- Returns:
0 if self and other are equal, 1 if self > other, and -1 self < other.
- Return type:
int
- _getstate(protocol: int = 3) tuple[source]¶
Get the state of the current time instance.
- Parameters:
protocol (int) – The protocol used to derive the state (default is 3).
- Returns:
The current state of the self instance.
- Return type:
tuple
- _hashcode¶
- _hour¶
- _microsecond¶
- _minute¶
- _second¶
- _tzstr() str[source]¶
Return a formatted timezone offset (+xx:xx) or an empty string.
- Returns:
The formatted timezone offset.
- Return type:
str
- badioffset() timedelta[source]¶
Return the timezone offset as timedelta, positive east of Asia/Tehran (negative west of UTC).
- Returns:
The offset from UTC.
- Return type:
- dst() timedelta[source]¶
Return 0 if DST is not in effect, or the DST offset (as timedelta positive eastward) if DST is in effect.
- Returns:
The DST offset from UTC.
- Return type:
Note
This is purely informational; the DST offset has already been added to the UTC offset returned by utcoffset() if applicable, so there’s no need to consult dst() unless you’re interested in displaying the DST info.
- property fold: int¶
Get the time fold. This is in the Autumn when the time is set back from daylight savings time to standard time and the same hour is repeated.
- Returns:
The time fold.
- Return type:
int
- classmethod fromisoformat(t_str: str)[source]¶
Construct a time from a string in one of the ISO 8601 formats.
- Parameters:
t_str (str) – An ISO formatted string.
- Returns:
An instance of time.
- Return type:
- property hour: float¶
Get the hour.
- Returns:
The hour.
- Return type:
float
- isoformat(timespec: str = 'auto') str[source]¶
Return the time formatted according to ISO.
The full format is ‘HH:MM:SS.mmmmmm+zz:zz’. By default, the fractional part is omitted if self.microsecond == 0.
The optional argument timespec specifies the number of additional terms of the time to include. Valid options are auto, hours, minutes, seconds, milliseconds and microseconds.
- Parameters:
timespec (str) – The specification is either auto (default) or milliseconds.
- Returns:
An ISO formatted string.
- Return type:
str
- max = badidatetime.time(24, 0, 3)¶
- property microsecond: int¶
Get the microsecond.
- Returns:
The microsecond.
- Return type:
int
- min = badidatetime.time(0, 0)¶
- property minute: float¶
Get the minute.
- Returns:
The minute.
- Return type:
float
- replace(hour: float = None, minute: float = None, second: float = None, microsecond: int = None, tzinfo: <property object at 0x75357bc6a430> = True, *, fold: int = None)[source]¶
Return a new time with new values for the specified fields.
- Parameters:
hour (float) – Hours (required)
minute (float) – Minutes (required)
second (float) – Seconds (default to zero)
microsecond (int) – Microseconds (default to zero)
tzinfo (tzinfo) – Timezone information (default to None)
fold (int) – (keyword only, default to zero)
- Returns:
A new time instance updated with the provided information.
- Return type:
- resolution = datetime.timedelta(microseconds=1)¶
- property second: float¶
Get the second.
- Returns:
The second.
- Return type:
float
- strftime(format: str) str[source]¶
Format using strftime(). The date part of the timestamp passed to underlying strftime should not be used.
- Parameters:
format (str) – The string format.
- Returns:
An updated format string.
- Return type:
str
- property tzinfo: tzinfo¶
Get the timezone info instance.
- Returns:
The timezone info instance.
- Return type:
- class badidatetime.datetime.timedelta¶
Bases:
objectDifference between two datetime values.
timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)
All arguments are optional and default to 0. Arguments may be integers or floats, and may be positive or negative.
- __abs__()¶
abs(self)
- __add__(value, /)¶
Return self+value.
- __bool__()¶
True if self else False
- __divmod__(value, /)¶
Return divmod(self, value).
- __eq__(value, /)¶
Return self==value.
- __floordiv__(value, /)¶
Return self//value.
- __ge__(value, /)¶
Return self>=value.
- __gt__(value, /)¶
Return self>value.
- __hash__()¶
Return hash(self).
- __le__(value, /)¶
Return self<=value.
- __lt__(value, /)¶
Return self<value.
- __mod__(value, /)¶
Return self%value.
- __mul__(value, /)¶
Return self*value.
- __ne__(value, /)¶
Return self!=value.
- __neg__()¶
-self
- classmethod __new__(*args, **kwargs)¶
- __pos__()¶
+self
- __radd__(value, /)¶
Return value+self.
- __rdivmod__(value, /)¶
Return divmod(value, self).
- __reduce__()¶
- __repr__()¶
Return repr(self).
- __rfloordiv__(value, /)¶
Return value//self.
- __rmod__(value, /)¶
Return value%self.
- __rmul__(value, /)¶
Return value*self.
- __rsub__(value, /)¶
Return value-self.
- __rtruediv__(value, /)¶
Return value/self.
- __str__()¶
Return str(self).
- __sub__(value, /)¶
Return self-value.
- __truediv__(value, /)¶
Return self/value.
- days¶
Number of days.
- max = datetime.timedelta(days=999999999, seconds=86399, microseconds=999999)¶
- microseconds¶
Number of microseconds (>= 0 and less than 1 second).
- min = datetime.timedelta(days=-999999999)¶
- resolution = datetime.timedelta(microseconds=1)¶
- seconds¶
Number of seconds (>= 0 and less than 1 day).
- total_seconds()¶
Total seconds in the duration.
- class badidatetime.datetime.timezone(offset: timedelta, name: str = <object object>)[source]¶
Bases:
tzinfo- __firstlineno__ = 2647¶
- __repr__() str[source]¶
Convert to formal string, for repr().
- Returns:
A string representing the date.
- Return type:
str
Note
>>> tz = timezone.utc >>> repr(tz) 'datetime.timezone.utc' >>> tz = timezone(timedelta(hours=-5), 'EST') >>> repr(tz) 'datetime.timezone(datetime.timedelta(-1, 68400), 'EST')'
- __static_attributes__ = ('_name', '_offset')¶
- __str__() str[source]¶
A string representation of the current timezone instance.
- Returns:
A string representation of the current timezone instance.
- Return type:
str
- classmethod _create(offset: timedelta, name: str = None) object[source]¶
Create an instance of tzinfo.
- _maxoffset = datetime.timedelta(seconds=86399, microseconds=999999)¶
- _minoffset = datetime.timedelta(days=-1, microseconds=1)¶
- _name¶
- _offset¶
- badi = badidatetime.BADI¶
- local = badidatetime.timezone(badidatetime.timedelta(seconds=12600))¶
- max = badidatetime.timezone(badidatetime.timedelta(seconds=86340))¶
- min = badidatetime.timezone(badidatetime.timedelta(days=-1, seconds=60))¶
- utc = badidatetime.timezone.utc¶
- class badidatetime.datetime.tzinfo¶
Bases:
objectAbstract base class for time zone info objects.
- classmethod __new__(*args, **kwargs)¶
- __reduce__()¶
-> (cls, state)
- dst(object, /)¶
datetime -> DST offset as timedelta positive east of UTC.
- fromutc(object, /)¶
datetime in UTC -> datetime in local time.
- tzname(object, /)¶
datetime -> string name of time zone.
- utcoffset(object, /)¶
datetime -> timedelta showing offset from UTC, negative values indicating West of UTC