pendulum API reference
78 public APIs from pendulum (sdispater/pendulum) — 6 classes, 17 functions, 55 methods. Signatures extracted by static analysis of the actual source.
Repository: sdispater/pendulum
| Kind | Count |
|---|---|
| Classes | 6 |
| Functions | 17 |
| Methods | 55 |
API list
func
src.pendulum._helpers.precise_diff(d1:datetime.datetime | datetime.date, d2:datetime.datetime | datetime.date) -> PreciseDiffCalculate a precise difference between two datetimes.
func
src.pendulum.date(year:int, month:int, day:int) -> DateCreate a new Date instance.
method
src.pendulum.date.Date.add(years:int=0, months:int=0, weeks:int=0, days:int=0) -> SelfAdd duration to the instance.
method
src.pendulum.date.Date.closest(dt1:date, dt2:date) -> SelfGet the closest date from the instance.
method
src.pendulum.date.Date.day_of_week() -> WeekDayReturns the day of the week (0-6).
method
src.pendulum.date.Date.day_of_year() -> intReturns the day of the year (1-366).
method
src.pendulum.date.Date.diff(dt:date | None=None, abs:bool=True) -> Interval[Date]Returns the difference between two Date objects as an Interval.
method
src.pendulum.date.Date.farthest(dt1:date, dt2:date) -> SelfGet the farthest date from the instance.
method
src.pendulum.date.Date.is_anniversary(dt:date | None=None) -> boolCheck if it's the anniversary.
method
src.pendulum.date.Date.is_future() -> boolDetermines if the instance is in the future, ie.
method
src.pendulum.date.Date.is_leap_year() -> boolDetermines if the instance is a leap year.
method
src.pendulum.date.Date.is_past() -> boolDetermines if the instance is in the past, ie.
method
src.pendulum.date.Date.next(day_of_week:WeekDay | None=None) -> SelfModify to the next occurrence of a given day of the week.
method
src.pendulum.date.Date.previous(day_of_week:WeekDay | None=None) -> SelfModify to the previous occurrence of a given day of the week.
method
src.pendulum.date.Date.subtract(years:int=0, months:int=0, weeks:int=0, days:int=0) -> SelfRemove duration from the instance.
method
src.pendulum.date.Date.to_date_string() -> strFormat the instance as date.
method
src.pendulum.date.Date.to_formatted_date_string() -> strFormat the instance as a readable date.
method
src.pendulum.datetime.DateTime.add(years:int=0, months:int=0, weeks:int=0, days:int=0, hours:int=0, minutes:int=0, seconds:float=0, microseconds:int=0) -> SelfAdd a duration to the instance.
method
src.pendulum.datetime.DateTime.at(hour:int, minute:int=0, second:int=0, microsecond:int=0) -> SelfReturns a new instance with the current time to a different time.
method
src.pendulum.datetime.DateTime.closest(*dts:datetime.datetime) -> SelfGet the closest date to the instance.
method
src.pendulum.datetime.DateTime.farthest(*dts:datetime.datetime) -> SelfGet the farthest date from the instance.
method
src.pendulum.datetime.DateTime.in_timezone(tz:str | Timezone | FixedTimezone) -> SelfSet the instance's timezone from a string or object.
method
src.pendulum.datetime.DateTime.in_tz(tz:str | Timezone | FixedTimezone) -> SelfSet the instance's timezone from a string or object.
method
src.pendulum.datetime.DateTime.is_anniversary(dt:datetime.datetime | None=None) -> boolCheck if its the anniversary.
method
src.pendulum.datetime.DateTime.is_future() -> boolDetermines if the instance is in the future, ie.
method
src.pendulum.datetime.DateTime.is_past() -> boolDetermines if the instance is in the past, ie.
method
src.pendulum.datetime.DateTime.naive() -> SelfReturn the DateTime without timezone information.
method
src.pendulum.datetime.DateTime.next(day_of_week:WeekDay | None=None, keep_time:bool=False) -> SelfModify to the next occurrence of a given day of the week.
method
src.pendulum.datetime.DateTime.subtract(years:int=0, months:int=0, weeks:int=0, days:int=0, hours:int=0, minutes:int=0, seconds:float=0, microseconds:int=0) -> SelfRemove duration from the instance.
method
src.pendulum.datetime.DateTime.to_atom_string() -> strFormat the instance as ATOM.
method
src.pendulum.datetime.DateTime.to_cookie_string() -> strFormat the instance as COOKIE.
method
src.pendulum.datetime.DateTime.to_datetime_string() -> strFormat the instance as date and time.
method
src.pendulum.datetime.DateTime.to_iso8601_string() -> strFormat the instance as ISO 8601.
method
src.pendulum.datetime.DateTime.to_rfc1036_string() -> strFormat the instance as RFC 1036.
method
src.pendulum.datetime.DateTime.to_rfc1123_string() -> strFormat the instance as RFC 1123.
method
src.pendulum.datetime.DateTime.to_rfc2822_string() -> strFormat the instance as RFC 2822.
method
src.pendulum.datetime.DateTime.to_rfc3339_string() -> strFormat the instance as RFC 3339.
method
src.pendulum.datetime.DateTime.to_rfc822_string() -> strFormat the instance as RFC 822.
method
src.pendulum.datetime.DateTime.to_rfc850_string() -> strFormat the instance as RFC 850.
method
src.pendulum.datetime.DateTime.to_rss_string() -> strFormat the instance as RSS.
method
src.pendulum.datetime.DateTime.to_time_string() -> strFormat the instance as time.
method
src.pendulum.datetime.DateTime.to_w3c_string() -> strFormat the instance as W3C.
func
src.pendulum.duration(days:float=0, seconds:float=0, microseconds:float=0, milliseconds:float=0, minutes:float=0, hours:float=0, weeks:float=0, years:float=0, months:float=0) -> DurationCreate a Duration instance.
class
src.pendulum.duration.DurationReplacement for the standard timedelta class.
method
src.pendulum.duration.Duration.as_timedelta() -> timedeltaReturn the interval as a native timedelta.
method
src.pendulum.duration.Duration.in_words(locale:str | None=None, separator:str=' ') -> strGet the current interval in words in the current locale.
class
src.pendulum.formatting.difference_formatter.DifferenceFormatterHandles formatting differences in text.
method
src.pendulum.formatting.difference_formatter.DifferenceFormatter.format(diff:Duration, is_now:bool=True, absolute:bool=False, locale:str | Locale | None=None) -> strFormats a difference.
func
src.pendulum.from_format(string:str, fmt:str, tz:str | Timezone=UTC, locale:str | None=None) -> DateTimeCreates a DateTime instance from a specific format.
func
src.pendulum.from_timestamp(timestamp:int | float, tz:str | Timezone=UTC) -> DateTimeCreate a DateTime instance from a timestamp.
func
src.pendulum.interval(start:DateTime, end:DateTime, absolute:bool=False) -> Interval[DateTime]Create an Interval instance.
class
src.pendulum.interval.IntervalAn interval of time between two datetimes.
method
src.pendulum.interval.Interval.as_duration() -> DurationReturn the Interval as a Duration.
method
src.pendulum.interval.Interval.in_months() -> intGives the duration of the Interval in full months.
method
src.pendulum.interval.Interval.in_words(locale:str | None=None, separator:str=' ') -> strGet the current interval in words in the current locale.
method
src.pendulum.interval.Interval.in_years() -> intGives the duration of the Interval in full years.
func
src.pendulum.local(year:int, month:int, day:int, hour:int=0, minute:int=0, second:int=0, microsecond:int=0) -> DateTimeReturn a DateTime in the local timezone.
class
src.pendulum.locales.locale.LocaleRepresent a specific locale.
func
src.pendulum.naive(year:int, month:int, day:int, hour:int=0, minute:int=0, second:int=0, microsecond:int=0, fold:int=1) -> DateTimeReturn a naive DateTime.
func
src.pendulum.now(tz:str | Timezone | None=None) -> DateTimeGet a DateTime instance for the current date and time.
func
src.pendulum.parsing.iso8601.parse_iso8601(text:str) -> datetime.datetime | datetime.date | datetime.time | DurationISO 8601 compliant parser.
func
src.pendulum.parsing.parse(text:str, **options:Any) -> datetime | date | time | _Interval | DurationParses a string with the given options.
func
src.pendulum.time(hour:int, minute:int=0, second:int=0, microsecond:int=0) -> TimeCreate a new Time instance.
class
src.pendulum.time.TimeRepresents a time instance as hour, minute, second, microsecond.
method
src.pendulum.time.Time.add(hours:int=0, minutes:int=0, seconds:int=0, microseconds:int=0) -> TimeAdd duration to the instance.
method
src.pendulum.time.Time.add_timedelta(delta:datetime.timedelta) -> TimeAdd timedelta duration to the instance.
method
src.pendulum.time.Time.closest(dt1:Time | time, dt2:Time | time) -> SelfGet the closest time from the instance.
method
src.pendulum.time.Time.diff(dt:time | None=None, abs:bool=True) -> DurationReturns the difference between two Time objects as an Duration.
method
src.pendulum.time.Time.farthest(dt1:Time | time, dt2:Time | time) -> SelfGet the farthest time from the instance.
method
src.pendulum.time.Time.subtract(hours:int=0, minutes:int=0, seconds:int=0, microseconds:int=0) -> TimeAdd duration to the instance.
method
src.pendulum.time.Time.subtract_timedelta(delta:datetime.timedelta) -> TimeRemove timedelta duration from the instance.
func
src.pendulum.today(tz:str | Timezone='local') -> DateTimeCreate a DateTime instance for today.
func
src.pendulum.tomorrow(tz:str | Timezone='local') -> DateTimeCreate a DateTime instance for tomorrow.
func
src.pendulum.tz.fixed_timezone(offset:int) -> FixedTimezoneReturn a Timezone instance given its offset in seconds.
func
src.pendulum.tz.local_timezone() -> Timezone | FixedTimezoneReturn the local timezone.
class
src.pendulum.tz.timezone.TimezoneRepresents a named timezone.
method
src.pendulum.tz.timezone.Timezone.convert(dt:_DT, raise_on_unknown_times:bool=False) -> _DTConverts a datetime in the current timezone.
func
src.pendulum.yesterday(tz:str | Timezone='local') -> DateTimeCreate a DateTime instance for yesterday.
About this data
These signatures were extracted from the public source of sdispater/pendulum
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.