API Docs¶
Utilities for managing the fiscal calendar.
- class fiscalyear.FiscalDate[source]¶
A wrapper around the builtin datetime.date class that provides the following attributes.
- ctime()¶
Return ctime() style string.
- day¶
- property fiscal_day: int¶
- Returns
The fiscal day
- property fiscal_month: int¶
- Returns
The fiscal month
- property fiscal_quarter: int¶
- Returns
The fiscal quarter
- property fiscal_year: int¶
- Returns
The fiscal year
- fromisoformat()¶
str -> Construct a date from the output of date.isoformat()
- fromordinal()¶
int -> date corresponding to a proleptic Gregorian ordinal.
- fromtimestamp()¶
timestamp -> local date from a POSIX timestamp (like time.time()).
- isocalendar()¶
Return a 3-tuple containing ISO year, week number, and weekday.
- isoformat()¶
Return string in ISO 8601 format, YYYY-MM-DD.
- isoweekday()¶
Return the day of the week represented by the date. Monday == 1 … Sunday == 7
- max = datetime.date(9999, 12, 31)¶
- min = datetime.date(1, 1, 1)¶
- month¶
- property next_fiscal_day: fiscalyear.FiscalDay¶
- Returns
The next fiscal day
- property next_fiscal_month: fiscalyear.FiscalMonth¶
- Returns
The next fiscal month
- property next_fiscal_quarter: fiscalyear.FiscalQuarter¶
- Returns
The next fiscal quarter
- property next_fiscal_year: fiscalyear.FiscalYear¶
- Returns
The next fiscal year
- property prev_fiscal_day: fiscalyear.FiscalDay¶
- Returns
The previous fiscal day
- property prev_fiscal_month: fiscalyear.FiscalMonth¶
- Returns
The previous fiscal month
- property prev_fiscal_quarter: fiscalyear.FiscalQuarter¶
- Returns
The previous fiscal quarter
- property prev_fiscal_year: fiscalyear.FiscalYear¶
- Returns
The previous fiscal year
- replace()¶
Return date with new specified fields.
- resolution = datetime.timedelta(days=1)¶
- strftime()¶
format -> strftime() style string.
- timetuple()¶
Return time tuple, compatible with time.localtime().
- today()¶
Current date or datetime: same as self.__class__.fromtimestamp(time.time()).
- toordinal()¶
Return proleptic Gregorian ordinal. January 1 of year 1 is day 1.
- weekday()¶
Return the day of the week represented by the date. Monday == 0 … Sunday == 6
- year¶
- class fiscalyear.FiscalDateTime[source]¶
A wrapper around the builtin datetime.datetime class that provides the following attributes.
- astimezone()¶
tz -> convert to local time in new timezone tz
- combine()¶
date, time -> datetime with same date and time fields
- ctime()¶
Return ctime() style string.
- date()¶
Return date object with same year, month and day.
- day¶
- dst()¶
Return self.tzinfo.dst(self).
- property fiscal_day: int¶
- Returns
The fiscal day
- property fiscal_month: int¶
- Returns
The fiscal month
- property fiscal_quarter: int¶
- Returns
The fiscal quarter
- property fiscal_year: int¶
- Returns
The fiscal year
- fold¶
- fromisoformat()¶
string -> datetime from datetime.isoformat() output
- fromordinal()¶
int -> date corresponding to a proleptic Gregorian ordinal.
- fromtimestamp()¶
timestamp[, tz] -> tz’s local time from POSIX timestamp.
- hour¶
- isocalendar()¶
Return a 3-tuple containing ISO year, week number, and weekday.
- isoformat()¶
[sep] -> string in ISO 8601 format, YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM]. sep is used to separate the year from the time, and defaults to ‘T’. timespec specifies what components of the time to include (allowed values are ‘auto’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, and ‘microseconds’).
- isoweekday()¶
Return the day of the week represented by the date. Monday == 1 … Sunday == 7
- max = datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)¶
- microsecond¶
- min = datetime.datetime(1, 1, 1, 0, 0)¶
- minute¶
- month¶
- property next_fiscal_day: fiscalyear.FiscalDay¶
- Returns
The next fiscal day
- property next_fiscal_month: fiscalyear.FiscalMonth¶
- Returns
The next fiscal month
- property next_fiscal_quarter: fiscalyear.FiscalQuarter¶
- Returns
The next fiscal quarter
- property next_fiscal_year: fiscalyear.FiscalYear¶
- Returns
The next fiscal year
- now()¶
Returns new datetime object representing current time local to tz.
- tz
Timezone object.
If no tz is specified, uses local timezone.
- property prev_fiscal_day: fiscalyear.FiscalDay¶
- Returns
The previous fiscal day
- property prev_fiscal_month: fiscalyear.FiscalMonth¶
- Returns
The previous fiscal month
- property prev_fiscal_quarter: fiscalyear.FiscalQuarter¶
- Returns
The previous fiscal quarter
- property prev_fiscal_year: fiscalyear.FiscalYear¶
- Returns
The previous fiscal year
- replace()¶
Return datetime with new specified fields.
- resolution = datetime.timedelta(microseconds=1)¶
- second¶
- strftime()¶
format -> strftime() style string.
- strptime()¶
string, format -> new datetime parsed from a string (like time.strptime()).
- time()¶
Return time object with same time but with tzinfo=None.
- timestamp()¶
Return POSIX timestamp as float.
- timetuple()¶
Return time tuple, compatible with time.localtime().
- timetz()¶
Return time object with same time and tzinfo.
- today()¶
Current date or datetime: same as self.__class__.fromtimestamp(time.time()).
- toordinal()¶
Return proleptic Gregorian ordinal. January 1 of year 1 is day 1.
- tzinfo¶
- tzname()¶
Return self.tzinfo.tzname(self).
- utcfromtimestamp()¶
Construct a naive UTC datetime from a POSIX timestamp.
- utcnow()¶
Return a new datetime representing UTC day and time.
- utcoffset()¶
Return self.tzinfo.utcoffset(self).
- utctimetuple()¶
Return UTC time tuple, compatible with time.localtime().
- weekday()¶
Return the day of the week represented by the date. Monday == 0 … Sunday == 6
- year¶
- class fiscalyear.FiscalDay(fiscal_year, fiscal_day)[source]¶
A class representing a single fiscal day.
Constructor.
- Parameters
fiscal_year (int) – The fiscal year
fiscal_day (int) – The fiscal day
- Returns
A newly constructed FiscalDay object
- Raises
ValueError – If fiscal_year or fiscal_day is out of range
- Return type
- classmethod current()[source]¶
Alternative constructor. Returns the current FiscalDay.
- Returns
A newly constructed FiscalDay object
- Return type
- property end: fiscalyear.FiscalDateTime¶
- Returns
End of the fiscal day
- property fiscal_day: int¶
- Returns
The fiscal day
- property fiscal_month: int¶
- Returns
The fiscal month
- property fiscal_quarter: int¶
- Returns
The fiscal quarter
- property fiscal_year: int¶
- Returns
The fiscal year
- property next_fiscal_day: fiscalyear.FiscalDay¶
- Returns
The next fiscal day
- property prev_fiscal_day: fiscalyear.FiscalDay¶
- Returns
The previous fiscal day
- property start: fiscalyear.FiscalDateTime¶
- Returns
Start of the fiscal day
- class fiscalyear.FiscalMonth(fiscal_year, fiscal_month)[source]¶
A class representing a single fiscal month.
Constructor.
- Parameters
fiscal_year (int) – The fiscal year
fiscal_month (int) – The fiscal month
- Returns
A newly constructed FiscalMonth object
- Raises
ValueError – If fiscal_year or fiscal_month is out of range
- Return type
- classmethod current()[source]¶
Alternative constructor. Returns the current FiscalMonth.
- Returns
A newly constructed FiscalMonth object
- Return type
- property end: fiscalyear.FiscalDateTime¶
- Returns
End of the fiscal month
- property fiscal_month: int¶
- Returns
The fiscal month
- property fiscal_year: int¶
- Returns
The fiscal year
- property next_fiscal_month: fiscalyear.FiscalMonth¶
- Returns
The next fiscal month
- property prev_fiscal_month: fiscalyear.FiscalMonth¶
- Returns
The previous fiscal month
- property start: fiscalyear.FiscalDateTime¶
- Returns
Start of the fiscal month
- class fiscalyear.FiscalQuarter(fiscal_year, fiscal_quarter)[source]¶
A class representing a single fiscal quarter.
Constructor.
- Parameters
fiscal_year (int) – The fiscal year
fiscal_quarter (int) – The fiscal quarter
- Returns
A newly constructed FiscalQuarter object
- Raises
ValueError – If fiscal_year or fiscal_quarter is out of range
- Return type
- classmethod current()[source]¶
Alternative constructor. Returns the current FiscalQuarter.
- Returns
A newly constructed FiscalQuarter object
- Return type
- property end: fiscalyear.FiscalDateTime¶
- Returns
The end of the fiscal quarter
- property fiscal_quarter: int¶
- Returns
The fiscal quarter
- property fiscal_year: int¶
- Returns
The fiscal year
- property next_fiscal_quarter: fiscalyear.FiscalQuarter¶
- Returns
The next fiscal quarter
- property prev_fiscal_quarter: fiscalyear.FiscalQuarter¶
- Returns
The previous fiscal quarter
- property start: fiscalyear.FiscalDateTime¶
- Returns
The start of the fiscal quarter
- class fiscalyear.FiscalYear(fiscal_year)[source]¶
A class representing a single fiscal year.
Constructor.
- Parameters
fiscal_year (int) – The fiscal year
- Returns
A newly constructed FiscalYear object
- Raises
ValueError – If
fiscal_year
is out of range- Return type
- classmethod current()[source]¶
Alternative constructor. Returns the current FiscalYear.
- Returns
A newly constructed FiscalYear object
- Return type
- property end: fiscalyear.FiscalDateTime¶
- Returns
End of the fiscal year
- property fiscal_year: int¶
- Returns
The fiscal year
- property isleap: bool¶
returns: True if the fiscal year contains a leap day, else False
- property next_fiscal_year: fiscalyear.FiscalYear¶
- Returns
The next fiscal year
- property prev_fiscal_year: fiscalyear.FiscalYear¶
- Returns
The previous fiscal year
- property q1: fiscalyear.FiscalQuarter¶
- Returns
The first quarter of the fiscal year
- property q2: fiscalyear.FiscalQuarter¶
- Returns
The second quarter of the fiscal year
- property q3: fiscalyear.FiscalQuarter¶
- Returns
The third quarter of the fiscal year
- property q4: fiscalyear.FiscalQuarter¶
- Returns
The fourth quarter of the fiscal year
- property start: fiscalyear.FiscalDateTime¶
- Returns
Start of the fiscal year
- fiscalyear.fiscal_calendar(start_year=None, start_month=None, start_day=None)[source]¶
A context manager that lets you modify the start of the fiscal calendar inside the scope of a with-statement.
- Parameters
start_year (Optional[str]) – Relationship between the start of the fiscal year and the calendar year. Possible values:
'previous'
or'same'
.start_month (Optional[int]) – The first month of the fiscal year
start_day (Optional[int]) – The first day of the first month of the fiscal year
- Raises
ValueError – If
start_year
is not'previous'
or'same'
ValueError – If
start_month
orstart_day
is out of range
- fiscalyear.setup_fiscal_calendar(start_year=None, start_month=None, start_day=None)[source]¶
Modify the start of the fiscal calendar.
- Parameters
start_year (Optional[str]) – Relationship between the start of the fiscal year and the calendar year. Possible values:
'previous'
or'same'
.start_month (Optional[int]) – The first month of the fiscal year
start_day (Optional[int]) – The first day of the first month of the fiscal year
- Raises
ValueError – If
start_year
is not'previous'
or'same'
ValueError – If
start_month
orstart_day
is out of range