Skip to main content

Utilities for managing the fiscal calendar

Project description

https://travis-ci.org/adamjstewart/fiscalyear.svg?branch=master https://codecov.io/gh/adamjstewart/fiscalyear/branch/master/graph/badge.svg https://readthedocs.org/projects/fiscalyear/badge/?version=latest

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 and fiscal quarter 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)

FiscalQuarter

The FiscalYear class also allows you to query information about a specific 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

FiscalDateTime

The start and end of each quarter 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 and quarter.

>>> c = FiscalDateTime.now()
>>> c
FiscalDateTime(2017, 4, 8, 20, 30, 31, 105323)
>>> c.fiscal_year
2017
>>> c.quarter
3
>>> c.next_quarter
FiscalQuarter(2017, 4)

FiscalDate

If you don’t care about the time component of the FiscalDateTime class, the FiscalDate class is right for you.

>>> d = FiscalDate.today()
>>> d
FiscalDate(2017, 4, 8)
>>> d.fiscal_year
2017
>>> d.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.

Project details


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.1.0.tar.gz (5.8 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: fiscalyear-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fiscalyear-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3fde4a12eeb72da446beb487e078adf1223a92d130520e589b82d7d1509701a2
MD5 30e36b259f3e72e4929abbf259335742
BLAKE2b-256 1cad1a278fd76462483cb22eee2eea4411ed44117a9cff3a0fcb5f0d8b82fcf5

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