Skip to main content

Utilities for managing the fiscal calendar

Project description

https://github.com/adamjstewart/fiscalyear/workflows/pytest/badge.svg?branch=master https://github.com/adamjstewart/fiscalyear/workflows/flake8/badge.svg?branch=master https://github.com/adamjstewart/fiscalyear/workflows/black/badge.svg?branch=master https://codecov.io/gh/adamjstewart/fiscalyear/branch/master/graph/badge.svg https://readthedocs.org/projects/fiscalyear/badge/?version=latest https://badge.fury.io/py/fiscalyear.svg https://anaconda.org/conda-forge/fiscalyear/badges/version.svg https://img.shields.io/badge/code%20style-black-000000.svg

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fiscalyear-0.3.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distributions

fiscalyear-0.3.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

fiscalyear-0.3.0-py2-none-any.whl (8.8 kB view details)

Uploaded Python 2

File details

Details for the file fiscalyear-0.3.0.tar.gz.

File metadata

  • Download URL: fiscalyear-0.3.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.7

File hashes

Hashes for fiscalyear-0.3.0.tar.gz
Algorithm Hash digest
SHA256 64f97b3a0ab6b2857d09f0016bd3aae37646a454a5c2c66e907fef03ae54a816
MD5 a4ce5bb7b210cb28c8c49d0c73ad1b16
BLAKE2b-256 15648cc7d15018eb41e04af990487d2a8557a36fb158d4a66f7119ebd5b447f3

See more details on using hashes here.

File details

Details for the file fiscalyear-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: fiscalyear-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.7

File hashes

Hashes for fiscalyear-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 56a57782d704915b59f3c5e9e8411a0326d1f7c480565eaa7173459d3721001a
MD5 42a10dd1a3927f29c84175bb6af56c50
BLAKE2b-256 2ff1564cccf16d205f3b8694b321ee571c0cf51802f2407cb1997f9c093b8320

See more details on using hashes here.

File details

Details for the file fiscalyear-0.3.0-py2-none-any.whl.

File metadata

  • Download URL: fiscalyear-0.3.0-py2-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.7

File hashes

Hashes for fiscalyear-0.3.0-py2-none-any.whl
Algorithm Hash digest
SHA256 1904d00c8b91f05825918014366df2880e86c0824c5ea36c30b9761c66662abc
MD5 c335b9a40584ee6d202819cfa06b5a72
BLAKE2b-256 d960914e5ebb95b014b0e7bc61842da4a53477ed54dec56fb70cc1ef1ff49cab

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page