Coder Social home page Coder Social logo

fiscalyear's Introduction

https://travis-ci.org/adamjstewart/fiscalyear.svg?branch=master 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)

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 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

You can also get the current FiscalQuarter with:

>>> FiscalQuarter.current()
FiscalQuarter(2018, 2)

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.

fiscalyear's People

Contributors

adamjstewart avatar pmav99 avatar curtlh avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.