Utils
conversions
Functions:
-
date_to_int–Converts a date object to an integer representation.
-
int_to_date–Converts an
intorstrobject to thedatetime.daterepresentation. -
date_to_datetime–Converts one object from date to the datetime object.
-
day_to_ordinal–Converts an integer day to an ordinal number, i.e., 1 -> 1st, 32 -> 32nd
-
next_month–Returns the next month after the provided
month. Original source. -
month_range–Range of the provided
monthas a tuple[start, end). -
current_timestamp–Returns the current timestamp in milliseconds, using UTC time.
-
cents_to_decimal–Converts the number of cents to a
decimal.Decimalobject. -
decimal_to_cents–Converts the decimal amount (
decimal.Decimalorintorfloat) to an integer value.
date_to_int
Converts a date object to an integer representation.
For example, the date(2025, 3, 10) gets converted to 20250310.
If month_only is set to True, the day will be removed from the date.
For example, the same date above gets converted to 202503.
Source code in actual/utils/conversions.py
int_to_date
Converts an int or str object to the datetime.date representation.
For example, the int 20250310 gets converted to date(2025, 3, 10).
Source code in actual/utils/conversions.py
date_to_datetime
Converts one object from date to the datetime object.
The reverse is possible directly by calling datetime.date().
Source code in actual/utils/conversions.py
day_to_ordinal
Converts an integer day to an ordinal number, i.e., 1 -> 1st, 32 -> 32nd
Source code in actual/utils/conversions.py
next_month
Returns the next month after the provided month. Original source.
Source code in actual/utils/conversions.py
month_range
Range of the provided month as a tuple [start, end).
The end date is not inclusive, as it represents the start of the next month.
Source code in actual/utils/conversions.py
current_timestamp
current_timestamp() -> int
cents_to_decimal
Converts the number of cents to a decimal.Decimal object.
When providing 500, the result will be decimal.Decimal(5.0).
Source code in actual/utils/conversions.py
decimal_to_cents
Converts the decimal amount (decimal.Decimal or int or float) to an integer value.
When providing decimal.Decimal(5.0), the result will be 500.