akkudoktoreos.utils.datetimeutil
Utility functions for date-time conversion tasks.
Functions:
to_datetime: Converts various date or time inputs to a timezone-aware or naive datetime object or formatted string.
to_duration: Converts various time delta inputs to a `timedelta`object.
to_timezone: Converts utc offset or location latitude and longitude to a timezone object.
Example usage:
# Date-time conversion >>> date_str = “2024-10-15” >>> date_obj = to_datetime(date_str) >>> print(date_obj) # Output: datetime object for ‘2024-10-15’
# Time delta conversion >>> to_duration(“2 days 5 hours”)
# Timezone detection >>> to_timezone(location=(40.7128, -74.0060))
Functions
|
Compares two Pendulum DateTime objects with precision, including DST and timezones. |
|
Returns the number of hours in the given date's day, considering DST transitions. |
Convert a date input into a Pendulum DateTime object or a formatted string, with optional timezone handling. |
|
|
Converts various input types into a Duration object using pendulum. |
Determines the timezone either by UTC offset, geographic location, or local system timezone. |
Classes
|
Encapsulates the result of comparing two Pendulum DateTime objects. |