THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
class DateTime: (source)
Provide a high-level interface for date and time operations.
All methods are class-level, using a configurable default timezone
and locale backed by pendulum for immutable datetime arithmetic.
| Class Method | _load |
Load configuration for timezone and locale. |
| Class Method | _set |
Set the default locale for date and time formatting. |
| Class Method | _set |
Set the default timezone for the application. |
| Class Method | add |
Add a combination of time units to a given date. |
| Class Method | add |
Add days to a given date. |
| Class Method | add |
Add hours to a given datetime. |
| Class Method | add |
Add minutes to a given datetime. |
| Class Method | average |
Return the middle datetime between two dates. |
| Class Method | closest |
Return the datetime closest to the given one among the candidates. |
| Class Method | convert |
Convert a date to the configured local timezone. |
| Class Method | datetime |
Create a datetime object in the configured timezone. |
| Class Method | diff |
Return the full Interval between two dates. |
| Class Method | diff |
Return a human-readable difference between two dates. |
| Class Method | diff |
Calculate the difference in days between two dates. |
| Class Method | diff |
Compute the difference in hours between two dates. |
| Class Method | duration |
Create a Duration instance representing a span of time. |
| Class Method | end |
Return the end of the given unit of time (e.g. 'hour', 'decade'). |
| Class Method | end |
Return the end of the day (23:59:59). |
| Class Method | end |
Return the end of the month (last day at 23:59:59). |
| Class Method | end |
Return the end of the week (Sunday 23:59:59). |
| Class Method | end |
Return the end of the year (December 31st at 23:59:59). |
| Class Method | farthest |
Return the datetime farthest from the given one among the candidates. |
| Class Method | first |
Return the first day of the given unit, optionally on a weekday. |
| Class Method | format |
Format a date in the local timezone. |
| Class Method | from |
Convert a standard datetime object to the configured timezone. |
| Class Method | from |
Parse a date string using explicit format tokens. |
| Class Method | from |
Convert a Unix timestamp to a datetime in the configured timezone. |
| Class Method | get |
Return the configured locale. |
| Class Method | get |
Return the configured timezone. |
| Class Method | get |
Return the ZoneInfo object for the configured timezone. |
| Class Method | interval |
Create an Interval instance between two datetimes. |
| Class Method | is |
Determine if the given date shares month and day with another date. |
| Class Method | is |
Determine if the given date is in the future. |
| Class Method | is |
Determine if the year of the given date is a leap year. |
| Class Method | is |
Determine if the given date is in the past. |
| Class Method | is |
Check if the given date is today. |
| Class Method | is |
Determine if the given date falls on a weekend. |
| Class Method | last |
Return the last day of the given unit, optionally on a weekday. |
| Class Method | local |
Create a datetime object in the local system timezone. |
| Class Method | naive |
Create a timezone-naive datetime object. |
| Class Method | next |
Move to the next occurrence of the given day of the week. |
| Class Method | now |
Get the current date and time. |
| Class Method | nth |
Return the n-th occurrence of a weekday within the given unit. |
| Class Method | parse |
Parse a date string and convert it to the configured timezone. |
| Class Method | previous |
Move to the previous occurrence of the given day of the week. |
| Class Method | start |
Return the start of the given unit of time (e.g. 'hour', 'decade'). |
| Class Method | start |
Return the start of the day (00:00:00). |
| Class Method | start |
Return the start of the month (first day at 00:00:00). |
| Class Method | start |
Return the start of the week (Monday 00:00:00). |
| Class Method | start |
Return the start of the year (January 1st at 00:00:00). |
| Class Method | subtract |
Subtract a combination of time units from a given date. |
| Class Method | today |
Return the current date without time component. |
| Class Method | tomorrow |
Return tomorrow's date in the specified or default timezone. |
| Class Method | yesterday |
Return the date for yesterday in the specified or default timezone. |
| Class Variable | __slots__ |
Undocumented |
| Class Variable | _locale |
Undocumented |
| Class Variable | _timezone |
Undocumented |
| Class Variable | _zoneinfo |
Undocumented |
Load configuration for timezone and locale.
| Parameters | |
timezonestr | None, optional | Name of the timezone (e.g., 'America/Mexico_City'). If None, uses the default. |
locale:str | None, optional | Language code (e.g., 'es', 'en', 'fr'). If None, uses the default. |
| Returns | |
None | This method does not return a value. |
Set the default timezone for the application.
| Parameters | |
timezonestr | Name of the timezone (e.g., 'America/Mexico_City'). |
| Returns | |
None | This method does not return a value. |
| Raises | |
ValueError | If the timezone is invalid. |
pendulum.DateTime, *, years: int = 0, months: int = 0, weeks: int = 0, days: int = 0, hours: int = 0, minutes: int = 0, seconds: float = 0, microseconds: int = 0) -> pendulum.DateTime:
(source)
¶
Add a combination of time units to a given date.
| Parameters | |
dt:pendulum.DateTime | The original datetime. |
years:int, optional | Number of years to add, by default 0. |
months:int, optional | Number of months to add, by default 0. |
weeks:int, optional | Number of weeks to add, by default 0. |
days:int, optional | Number of days to add, by default 0. |
hours:int, optional | Number of hours to add, by default 0. |
minutes:int, optional | Number of minutes to add, by default 0. |
seconds:float, optional | Number of seconds to add, by default 0. |
microseconds:int, optional | Number of microseconds to add, by default 0. |
| Returns | |
pendulum.DateTime | The resulting datetime after adding the specified units. |
Add days to a given date.
| Parameters | |
dt:pendulum.DateTime | The original date. |
days:int | Number of days to add. |
| Returns | |
pendulum.DateTime | The resulting date after adding the specified days. |
Add hours to a given datetime.
| Parameters | |
dt:pendulum.DateTime | The original datetime. |
hours:int | Number of hours to add. |
| Returns | |
pendulum.DateTime | The resulting datetime after adding the specified hours. |
Add minutes to a given datetime.
| Parameters | |
dt:pendulum.DateTime | The original datetime. |
minutes:int | Number of minutes to add. |
| Returns | |
pendulum.DateTime | The resulting datetime after adding the specified minutes. |
pendulum.DateTime, dt2: pendulum.DateTime | None = None) -> pendulum.DateTime:
(source)
¶
Return the middle datetime between two dates.
| Parameters | |
dt1:pendulum.DateTime | The reference datetime. |
dt2:pendulum.DateTime | None, optional | The datetime to average with. If None, uses the current datetime in the configured timezone. |
| Returns | |
pendulum.DateTime | The datetime halfway between dt1 and dt2. |
pendulum.DateTime, *others: pendulum.DateTime) -> pendulum.DateTime:
(source)
¶
Return the datetime closest to the given one among the candidates.
| Parameters | |
dt:pendulum.DateTime | The reference datetime. |
*others:pendulum.DateTime | Candidate datetimes to compare against the reference. |
| Returns | |
pendulum.DateTime | The candidate closest to dt. |
str | stdlib_datetime | pendulum.DateTime) -> pendulum.DateTime:
(source)
¶
Convert a date to the configured local timezone.
| Parameters | |
dt:str | datetime.datetime | pendulum.DateTime | Date to convert. Accepts string, standard datetime, or pendulum.DateTime. |
| Returns | |
pendulum.DateTime | The date converted to the configured timezone. |
int, month: int = 1, day: int = 1, hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0, tz: str | None = None) -> pendulum.DateTime:
(source)
¶
Create a datetime object in the configured timezone.
| Parameters | |
year:int | Year component. |
month:int, optional | Month component, by default 1. |
day:int, optional | Day component, by default 1. |
hour:int, optional | Hour component, by default 0. |
minute:int, optional | Minute component, by default 0. |
second:int, optional | Second component, by default 0. |
microsecond:int, optional | Microsecond component, by default 0. |
tz:str | None, optional | Specific timezone name. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | Datetime object in the specified or default timezone. |
pendulum.DateTime, dt2: pendulum.DateTime | None = None, *, absolute: bool = True) -> pendulum.Interval:
(source)
¶
Return the full Interval between two dates.
| Parameters | |
dt1:pendulum.DateTime | The reference datetime. |
dt2:pendulum.DateTime | None, optional | The datetime to compare against. If None, uses the current datetime in the configured timezone. |
absolute:bool, optional | Whether to return an always-positive interval, by default True. |
| Returns | |
pendulum.Interval | The Interval instance exposing in_years()/in_months()/ in_weeks()/in_days()/in_hours()/in_minutes()/in_seconds(). |
pendulum.DateTime, other: pendulum.DateTime | None = None, *, absolute: bool = False, locale: str | None = None) -> str:
(source)
¶
Return a human-readable difference between two dates.
| Parameters | |
dt:pendulum.DateTime | The reference datetime. |
other:pendulum.DateTime | None, optional | The datetime to compare against. If None, uses the current datetime. |
absolute:bool, optional | Whether to remove modifiers such as 'ago' or 'from now', by default False. |
locale:str | None, optional | Locale to use for the phrase. If None, uses the configured default. |
| Returns | |
str | A human-readable string such as '3 weeks ago'. |
Calculate the difference in days between two dates.
| Parameters | |
dt1:pendulum.DateTime | The first date. |
dt2:pendulum.DateTime | The second date. |
| Returns | |
int | The difference in days between the two dates. |
Compute the difference in hours between two dates.
| Parameters | |
dt1:pendulum.DateTime | The first datetime. |
dt2:pendulum.DateTime | The second datetime. |
| Returns | |
int | The difference in hours between the two dates. |
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) -> pendulum.Duration:
(source)
¶
Create a Duration instance representing a span of time.
| Parameters | |
days:float, optional | Number of days, by default 0. |
seconds:float, optional | Number of seconds, by default 0. |
microseconds:float, optional | Number of microseconds, by default 0. |
milliseconds:float, optional | Number of milliseconds, by default 0. |
minutes:float, optional | Number of minutes, by default 0. |
hours:float, optional | Number of hours, by default 0. |
weeks:float, optional | Number of weeks, by default 0. |
years:float, optional | Number of years, by default 0. |
months:float, optional | Number of months, by default 0. |
| Returns | |
pendulum.Duration | The resulting Duration instance. |
str, dt: pendulum.DateTime | None = None, tz: str | None = None) -> pendulum.DateTime:
(source)
¶
Return the end of the given unit of time (e.g. 'hour', 'decade').
| Parameters | |
unit:str | Unit of time: 'second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year', 'decade' or 'century'. |
dt:pendulum.DateTime | None, optional | The datetime to use. If None, uses the current datetime. |
tz:str | None, optional | The timezone to use. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | The datetime at the end of the given unit. |
pendulum.DateTime | None = None, tz: str | None = None) -> pendulum.DateTime:
(source)
¶
Return the end of the day (23:59:59).
| Parameters | |
dt:pendulum.DateTime | None, optional | The datetime to use. If None, uses the current datetime. |
tz:str | None, optional | The timezone to use. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | The datetime at the end of the day. |
pendulum.DateTime | None = None, tz: str | None = None) -> pendulum.DateTime:
(source)
¶
Return the end of the month (last day at 23:59:59).
| Parameters | |
dt:pendulum.DateTime | None, optional | The datetime to use. If None, uses the current datetime. |
tz:str | None, optional | The timezone to use. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | The datetime at the end of the month. |
pendulum.DateTime | None = None, tz: str | None = None) -> pendulum.DateTime:
(source)
¶
Return the end of the week (Sunday 23:59:59).
| Parameters | |
dt:pendulum.DateTime | None, optional | The datetime to use. If None, uses the current datetime. |
tz:str | None, optional | The timezone to use. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | The datetime at the end of the week. |
pendulum.DateTime | None = None, tz: str | None = None) -> pendulum.DateTime:
(source)
¶
Return the end of the year (December 31st at 23:59:59).
| Parameters | |
dt:pendulum.DateTime | None, optional | The datetime to use. If None, uses the current datetime. |
tz:str | None, optional | The timezone to use. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | The datetime at the end of the year. |
pendulum.DateTime, *others: pendulum.DateTime) -> pendulum.DateTime:
(source)
¶
Return the datetime farthest from the given one among the candidates.
| Parameters | |
dt:pendulum.DateTime | The reference datetime. |
*others:pendulum.DateTime | Candidate datetimes to compare against the reference. |
| Returns | |
pendulum.DateTime | The candidate farthest from dt. |
pendulum.DateTime, unit: str, day_of_week: int | None = None) -> pendulum.DateTime:
(source)
¶
Return the first day of the given unit, optionally on a weekday.
| Parameters | |
dt:pendulum.DateTime | The original datetime. |
unit:str | Unit of time: 'month', 'quarter' or 'year'. |
dayint | None, optional | Constrain the result to a specific day of the week
(e.g. pendulum.MONDAY). If None, returns the first day
of the unit regardless of weekday. |
| Returns | |
pendulum.DateTime | The resulting datetime. |
stdlib_datetime | pendulum.DateTime, tz: str | None = None) -> pendulum.DateTime:
(source)
¶
Convert a standard datetime object to the configured timezone.
| Parameters | |
dt:datetime.datetime or pendulum.DateTime | Datetime object to convert. |
tz:str or None, optional | Specific timezone name. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | Datetime object in the specified or default timezone. |
| Raises | |
TypeError | If the input type is not supported. |
str, fmt: str, tz: str | None = None, locale: str | None = None) -> pendulum.DateTime:
(source)
¶
Parse a date string using explicit format tokens.
| Parameters | |
datestr | Date string to parse. |
fmt:str | Format string using pendulum's custom tokens (e.g. 'YYYY-MM-DD'). |
tz:str | None, optional | Specific timezone name. If None, uses the configured default. |
locale:str | None, optional | Locale to use while parsing localized tokens (e.g. month or day names). If None, uses the configured default. |
| Returns | |
pendulum.DateTime | Parsed datetime object in the specified or default timezone. |
Convert a Unix timestamp to a datetime in the configured timezone.
| Parameters | |
timestamp:int | float | Unix timestamp to convert. |
tz:str | None, optional | Specific timezone name. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | Datetime object in the specified or default timezone. |
Return the ZoneInfo object for the configured timezone.
| Returns | |
ZoneInfo | The ZoneInfo instance corresponding to the configured timezone. |
pendulum.DateTime, end: pendulum.DateTime, *, absolute: bool = False) -> pendulum.Interval:
(source)
¶
Create an Interval instance between two datetimes.
| Parameters | |
start:pendulum.DateTime | The start of the interval. |
end:pendulum.DateTime | The end of the interval. |
absolute:bool, optional | Whether to force a positive interval regardless of the order of start and end, by default False. |
| Returns | |
pendulum.Interval | The resulting Interval instance. |
pendulum.DateTime, other: pendulum.DateTime | None = None) -> bool:
(source)
¶
Determine if the given date shares month and day with another date.
| Parameters | |
dt:pendulum.DateTime | The reference date (e.g. a date of birth). |
other:pendulum.DateTime | None, optional | The date to compare against. If None, uses the current datetime in the configured timezone. |
| Returns | |
bool | True if both dates share the same month and day, False otherwise. |
Determine if the given date is in the future.
| Parameters | |
dt:pendulum.DateTime | The datetime to check. |
| Returns | |
bool | True if the date is in the future, False otherwise. |
Determine if the year of the given date is a leap year.
| Parameters | |
dt:pendulum.DateTime | None, optional | The datetime to check. If None, uses the current datetime. |
| Returns | |
bool | True if the year is a leap year, False otherwise. |
Determine if the given date is in the past.
| Parameters | |
dt:pendulum.DateTime | The datetime to check. |
| Returns | |
bool | True if the date is in the past, False otherwise. |
Check if the given date is today.
| Parameters | |
dt:pendulum.DateTime | The datetime to check. |
| Returns | |
bool | True if the date is today, False otherwise. |
Determine if the given date falls on a weekend.
| Parameters | |
dt:pendulum.DateTime | None, optional | The datetime to check. If None, uses the current datetime. |
| Returns | |
bool | True if the date is Saturday or Sunday, False otherwise. |
pendulum.DateTime, unit: str, day_of_week: int | None = None) -> pendulum.DateTime:
(source)
¶
Return the last day of the given unit, optionally on a weekday.
| Parameters | |
dt:pendulum.DateTime | The original datetime. |
unit:str | Unit of time: 'month', 'quarter' or 'year'. |
dayint | None, optional | Constrain the result to a specific day of the week
(e.g. pendulum.FRIDAY). If None, returns the last day
of the unit regardless of weekday. |
| Returns | |
pendulum.DateTime | The resulting datetime. |
int, month: int = 1, day: int = 1, hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0) -> pendulum.DateTime:
(source)
¶
Create a datetime object in the local system timezone.
| Parameters | |
year:int | Year component. |
month:int, optional | Month component, by default 1. |
day:int, optional | Day component, by default 1. |
hour:int, optional | Hour component, by default 0. |
minute:int, optional | Minute component, by default 0. |
second:int, optional | Second component, by default 0. |
microsecond:int, optional | Microsecond component, by default 0. |
| Returns | |
pendulum.DateTime | Datetime object expressed in the local system timezone. |
int, month: int = 1, day: int = 1, hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0) -> pendulum.DateTime:
(source)
¶
Create a timezone-naive datetime object.
| Parameters | |
year:int | Year component. |
month:int, optional | Month component, by default 1. |
day:int, optional | Day component, by default 1. |
hour:int, optional | Hour component, by default 0. |
minute:int, optional | Minute component, by default 0. |
second:int, optional | Second component, by default 0. |
microsecond:int, optional | Microsecond component, by default 0. |
| Returns | |
pendulum.DateTime | Datetime object with no timezone information attached. |
pendulum.DateTime, day_of_week: int | None = None, *, keep_time: bool = False) -> pendulum.DateTime:
(source)
¶
Move to the next occurrence of the given day of the week.
| Parameters | |
dt:pendulum.DateTime | The original datetime. |
dayint | None, optional | Target day of the week (e.g. pendulum.WEDNESDAY). If None,
uses the day of the week of dt. |
keepbool, optional | Whether to keep the time component instead of resetting it to midnight, by default False. |
| Returns | |
pendulum.DateTime | The datetime of the next matching day. |
Get the current date and time.
| Parameters | |
tz:str | None, optional | Specific timezone name. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | The current date and time in the specified or default timezone. |
pendulum.DateTime, unit: str, nth: int, day_of_week: int) -> pendulum.DateTime:
(source)
¶
Return the n-th occurrence of a weekday within the given unit.
| Parameters | |
dt:pendulum.DateTime | The original datetime. |
unit:str | Unit of time: 'month', 'quarter' or 'year'. |
nth:int | The occurrence index to look for (1-based). |
dayint | Target day of the week (e.g. pendulum.MONDAY). |
| Returns | |
pendulum.DateTime | The resulting datetime. |
| Raises | |
PendulumException | If the given occurrence does not exist within the unit. |
str, tz: str | None = None, *, strict: bool = True) -> pendulum.DateTime:
(source)
¶
Parse a date string and convert it to the configured timezone.
| Parameters | |
datestr | Date string to parse. |
tz:str | None, optional | Specific timezone name. If None, uses the configured default. |
strict:bool, optional | Whether to use strict parsing mode, by default True. |
| Returns | |
pendulum.DateTime | Parsed datetime object in the specified or default timezone. |
pendulum.DateTime, day_of_week: int | None = None, *, keep_time: bool = False) -> pendulum.DateTime:
(source)
¶
Move to the previous occurrence of the given day of the week.
| Parameters | |
dt:pendulum.DateTime | The original datetime. |
dayint | None, optional | Target day of the week (e.g. pendulum.WEDNESDAY). If None,
uses the day of the week of dt. |
keepbool, optional | Whether to keep the time component instead of resetting it to midnight, by default False. |
| Returns | |
pendulum.DateTime | The datetime of the previous matching day. |
str, dt: pendulum.DateTime | None = None, tz: str | None = None) -> pendulum.DateTime:
(source)
¶
Return the start of the given unit of time (e.g. 'hour', 'decade').
| Parameters | |
unit:str | Unit of time: 'second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year', 'decade' or 'century'. |
dt:pendulum.DateTime | None, optional | The datetime to use. If None, uses the current datetime. |
tz:str | None, optional | The timezone to use. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | The datetime at the start of the given unit. |
pendulum.DateTime | None = None, tz: str | None = None) -> pendulum.DateTime:
(source)
¶
Return the start of the day (00:00:00).
| Parameters | |
dt:pendulum.DateTime | None, optional | The datetime to use. If None, uses the current datetime. |
tz:str | None, optional | The timezone to use. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | The datetime at the start of the day. |
pendulum.DateTime | None = None, tz: str | None = None) -> pendulum.DateTime:
(source)
¶
Return the start of the month (first day at 00:00:00).
| Parameters | |
dt:pendulum.DateTime | None, optional | The datetime to use. If None, uses the current datetime. |
tz:str | None, optional | The timezone to use. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | The datetime at the start of the month. |
pendulum.DateTime | None = None, tz: str | None = None) -> pendulum.DateTime:
(source)
¶
Return the start of the week (Monday 00:00:00).
| Parameters | |
dt:pendulum.DateTime | None, optional | The datetime to use. If None, uses the current datetime. |
tz:str | None, optional | The timezone to use. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | The datetime at the start of the week. |
pendulum.DateTime | None = None, tz: str | None = None) -> pendulum.DateTime:
(source)
¶
Return the start of the year (January 1st at 00:00:00).
| Parameters | |
dt:pendulum.DateTime | None, optional | The datetime to use. If None, uses the current datetime. |
tz:str | None, optional | The timezone to use. If None, uses the configured default. |
| Returns | |
pendulum.DateTime | The datetime at the start of the year. |
pendulum.DateTime, *, years: int = 0, months: int = 0, weeks: int = 0, days: int = 0, hours: int = 0, minutes: int = 0, seconds: float = 0, microseconds: int = 0) -> pendulum.DateTime:
(source)
¶
Subtract a combination of time units from a given date.
| Parameters | |
dt:pendulum.DateTime | The original datetime. |
years:int, optional | Number of years to subtract, by default 0. |
months:int, optional | Number of months to subtract, by default 0. |
weeks:int, optional | Number of weeks to subtract, by default 0. |
days:int, optional | Number of days to subtract, by default 0. |
hours:int, optional | Number of hours to subtract, by default 0. |
minutes:int, optional | Number of minutes to subtract, by default 0. |
seconds:float, optional | Number of seconds to subtract, by default 0. |
microseconds:int, optional | Number of microseconds to subtract, by default 0. |
| Returns | |
pendulum.DateTime | The resulting datetime after subtracting the specified units. |
Return the current date without time component.
| Parameters | |
tz:str | None, optional | Specific timezone name. If None, uses the configured default. |
| Returns | |
pendulum.Date | The current date in the specified or default timezone. |
Return tomorrow's date in the specified or default timezone.
| Parameters | |
tz:str | None, optional | Timezone name. If None, uses the configured default. |
| Returns | |
pendulum.Date | The date for tomorrow in the specified or default timezone. |