Overview
fiscalyear is a small, lightweight Python module providing helpful utilities for managing the fiscal calendar. It is designed as an extension of the built-in datetime and calendar modules, adding the ability to query the fiscal year, fiscal quarter, fiscal month, and fiscal day of a date or datetime object.
Basic Usage
fiscalyear provides several useful classes.
FiscalYear
The FiscalYear class provides an object for storing information about the start and end of a particular fiscal year.
>>> from fiscalyear import *
>>> a = FiscalYear(2017)
>>> a.start
FiscalDateTime(2016, 10, 1, 0, 0)
>>> a.end
FiscalDateTime(2017, 9, 30, 23, 59, 59)
>>> a.isleap
False
You can also get the current FiscalYear with:
>>> FiscalYear.current()
FiscalYear(2018)
FiscalQuarter
The FiscalYear class also allows you to query information about a specific fiscal quarter.
>>> a.q3.start
FiscalDateTime(2017, 4, 1, 0, 0)
>>> a.q3.end
FiscalDateTime(2017, 6, 30, 23, 59, 59)
These objects represent the standalone FiscalQuarter class.
>>> b = FiscalQuarter(2017, 3)
>>> b.start
FiscalDateTime(2017, 4, 1, 0, 0)
>>> b.end
FiscalDateTime(2017, 6, 30, 23, 59, 59)
>>> a.q3 == b
True
>>> b in a
True
>>> b.next_fiscal_quarter
FiscalQuarter(2017, 4)
You can also get the current FiscalQuarter with:
>>> FiscalQuarter.current()
FiscalQuarter(2018, 2)
FiscalMonth
The FiscalMonth class allows you to keep track of the fiscal month.
>>> c = FiscalMonth(2017, 9)
>>> c.start
FiscalDateTime(2017, 6, 1, 0, 0)
>>> c.end
FiscalDateTime(2017, 6, 30, 23, 59, 59)
>>> c in a
True
>>> c in b
True
>>> c.next_fiscal_month
FiscalMonth(2017, 10)
You can also get the current FiscalMonth with:
>>> FiscalMonth.current()
FiscalMonth(2018, 4)
FiscalDay
To keep track of the fiscal day, use the FiscalDay class.
>>> d = FiscalDay(2017, 250)
>>> d.start
FiscalDateTime(2017, 6, 6, 0, 0)
>>> d.end
FiscalDateTime(2017, 6, 6, 23, 59, 59)
>>> d in a
True
>>> d in b
True
>>> d in c
True
>>> d.next_fiscal_day
FiscalDay(2017, 251)
You can also get the current FiscalDay with:
>>> FiscalDay.current()
FiscalDay(2018, 94)
FiscalDateTime
The start and end of each of the above objects are stored as instances of the FiscalDateTime class. This class provides all of the same features as the datetime class, with the addition of the ability to query the fiscal year, fiscal quarter, fiscal month, and fiscal day.
>>> e = FiscalDateTime.now()
>>> e
FiscalDateTime(2017, 4, 8, 20, 30, 31, 105323)
>>> e.fiscal_year
2017
>>> e.fiscal_quarter
3
>>> e.next_fiscal_quarter
FiscalQuarter(2017, 4)
>>> e.fiscal_month
7
>>> e.fiscal_day
190
FiscalDate
If you don’t care about the time component of the FiscalDateTime class, the FiscalDate class is right for you.
>>> f = FiscalDate.today()
>>> f
FiscalDate(2017, 4, 8)
>>> f.fiscal_year
2017
>>> f.prev_fiscal_year
FiscalYear(2016)
Installation
fiscalyear has no dependencies, making it simple and easy to install. The recommended way to install fiscalyear is with pip.
$ pip install fiscalyear
For alternate installation methods, see the Installation Documentation.
Documentation
Documentation is hosted on Read the Docs.
Metadata
Release files for fiscalyear 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fiscalyear-0.4.0.tar.gz | 8.8 kB | Without provenance | Details for fiscalyear-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fiscalyear-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for fiscalyear-0.4.0-py3-none-any.whl |
Total release size: 17.3 kB
Release files / fiscalyear-0.4.0.tar.gz
| Download URL | fiscalyear-0.4.0.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12857a48bd7b97bda78d833b29e81f30ec5aa018241f690e714b472b25fa1b47
|
|
BLAKE2b-256 checksum How to use checksums |
58d003cabc6369fe1f0dcb73339ec1bf11ddb62d25ba03f531deacfd1078655a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.7.1 requests/2.25.1 setuptools/58.1.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.9
|
Release files / fiscalyear-0.4.0-py3-none-any.whl
| Download URL | fiscalyear-0.4.0-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8adb8022a76cc52974d059d176ec3f33b2d7a6c1f72ac356702bc70e1e5e4d92
|
|
BLAKE2b-256 checksum How to use checksums |
41ea6e5568ef338ba918be8c8fccc0a717d824c13187fe5cb9e8ad8530d113d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.7.1 requests/2.25.1 setuptools/58.1.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.9
|
Security for fiscalyear 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.