### Install fiscalyear with pip Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/installation.md Use this command to install the fiscalyear module using pip, the standard Python package installer. ```console pip install fiscalyear ``` -------------------------------- ### Change Fiscal Year Start Day Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/advanced_usage.md Shows how to set the starting day of the fiscal year. The start day must be a valid day within the selected start month. ```python >>> a.start.day 1 >>> fiscalyear.setup_fiscal_calendar(start_day=6) >>> a.start.day 6 ``` -------------------------------- ### Install and Load fiscalyear with Spack Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/installation.md For HPC environments, use Spack to install and load the py-fiscalyear module. ```console spack install py-fiscalyear spack load py-fiscalyear ``` -------------------------------- ### Build Documentation Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/documentation.md Navigate to the docs directory and use the Makefile to build the HTML documentation. Requires sphinx and sphinx_rtd_theme to be installed. ```console cd docs make html ``` -------------------------------- ### Install fiscalyear with Anaconda Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/installation.md Use this command to install the fiscalyear module using the conda package manager from the conda-forge channel. ```console conda install -c conda-forge fiscalyear ``` -------------------------------- ### Change Fiscal Year Start Month Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/advanced_usage.md Illustrates how to modify the starting month of the fiscal year. The start month can be set to any valid month number. ```python >>> a.start.month 10 >>> fiscalyear.setup_fiscal_calendar(start_month=4) >>> a.start.month 4 ``` -------------------------------- ### Iterate with Different Fiscal Calendars Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/advanced_usage.md Shows an example of using the `fiscal_calendar` context manager within a for-loop to process data under various fiscal calendar configurations. ```python calendars = [ ('previous', 10, 1), ('same', 4, 6), ... ] for calendar in calendars: with fiscal_calendar(*calendar): # do stuff ``` -------------------------------- ### Instantiate and Query FiscalYear Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/basic_usage.md Create a FiscalYear object and access its start, end, and leap status. The fiscal year starts on October 1st. ```python >>> 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 ``` -------------------------------- ### Change Fiscal Year Start Year Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/advanced_usage.md Demonstrates how to change the fiscal year definition from starting in the 'previous' calendar year to the 'same' calendar year. This affects the year attribute of the fiscal year's start date. ```python >>> a.start.year 2016 >>> fiscalyear.setup_fiscal_calendar(start_year='same') >>> a.start.year 2017 ``` -------------------------------- ### Recreate UK Fiscal Calendar Temporarily Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/advanced_usage.md Demonstrates recreating the UK's specific fiscal calendar (start year 'same', month 4, day 6) using the `fiscal_calendar` context manager for temporary application. ```python >>> with fiscal_calendar('same', 4, 6): ... a.start ... FiscalDateTime(2017, 4, 6, 0, 0) ``` -------------------------------- ### Instantiate and Query FiscalMonth Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/basic_usage.md Create a FiscalMonth object and access its start and end dates. Verify containment within FiscalYear and FiscalQuarter objects. ```python >>> 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) ``` -------------------------------- ### Instantiate and Query FiscalQuarter Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/basic_usage.md Create a FiscalQuarter object and access its start and end dates. Verify equality and containment with a FiscalYear object. ```python >>> 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) ``` -------------------------------- ### Set All Fiscal Calendar Parameters Simultaneously Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/advanced_usage.md Provides a concise method to update all fiscal calendar parameters (start year, month, and day) at once using a single function call. ```python >>> fiscalyear.setup_fiscal_calendar('same', 4, 6) ``` -------------------------------- ### Verify Global Fiscal Calendar Changes Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/advanced_usage.md Confirms the combined effect of changing the start year, month, and day on the fiscal year's start and end dates. This reflects the globally updated calendar settings. ```python >>> a.start FiscalDateTime(2017, 4, 6, 0, 0) >>> a.end FiscalDateTime(2018, 4, 5, 23, 59, 59) ``` -------------------------------- ### Get Current FiscalMonth Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/basic_usage.md Retrieve the current fiscal month object. ```python >>> FiscalMonth.current() FiscalMonth(2018, 4) ``` -------------------------------- ### Get Current FiscalDay Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/basic_usage.md Retrieve the current fiscal day object. ```python >>> FiscalDay.current() FiscalDay(2018, 94) ``` -------------------------------- ### Get Current FiscalYear Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/basic_usage.md Retrieve the current fiscal year object. ```python >>> FiscalYear.current() FiscalYear(2018) ``` -------------------------------- ### Get Current FiscalQuarter Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/basic_usage.md Retrieve the current fiscal quarter object. ```python >>> FiscalQuarter.current() FiscalQuarter(2018, 2) ``` -------------------------------- ### Instantiate and Query FiscalDay Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/basic_usage.md Create a FiscalDay object using the day number within the fiscal year and access its start and end dates. Verify containment within FiscalYear, FiscalQuarter, and FiscalMonth objects. ```python >>> 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) ``` -------------------------------- ### Query FiscalQuarter within FiscalYear Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/basic_usage.md Access the start and end dates of a specific fiscal quarter within a FiscalYear object. ```python >>> a.q3.start FiscalDateTime(2017, 4, 1, 0, 0) >>> a.q3.end FiscalDateTime(2017, 6, 30, 23, 59, 59) ``` -------------------------------- ### Run pytest command Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/testing.md Clone the repository, navigate to the root directory, and execute the pytest command to run the test suite. ```console $ git clone https://github.com/adamjstewart/fiscalyear.git $ cd fiscalyear $ pytest ============================ test session starts ============================= platform darwin -- Python 2.7.13, pytest-3.0.5, py-1.4.32, pluggy-0.4.0 rootdir: /Users/Adam/fiscalyear, inifile: plugins: cov-2.3.1 collected 66 items test_fiscalyear.py .................................................................. ========================= 66 passed in 0.21 seconds ========================== ``` -------------------------------- ### Instantiate and Query FiscalDateTime Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/basic_usage.md Create a FiscalDateTime object and access its fiscal year, quarter, month, and day properties. This class extends Python's datetime. ```python >>> 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 ``` -------------------------------- ### Import FiscalYear Module Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/advanced_usage.md Import the fiscalyear module to begin using its functionalities. This is a prerequisite for all subsequent operations. ```python import fiscalyear >>> a = fiscalyear.FiscalYear(2017) ``` -------------------------------- ### Instantiate and Query FiscalDate Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/basic_usage.md Create a FiscalDate object and access its fiscal year and previous fiscal year properties. This class is similar to datetime.date but with fiscal period awareness. ```python >>> f = FiscalDate.today() >>> f FiscalDate(2017, 4, 8) >>> f.fiscal_year 2017 >>> f.prev_fiscal_year FiscalYear(2016) ``` -------------------------------- ### Run Coverage Tests Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/coverage.md Execute local coverage tests for the fiscalyear project using pytest with the --cov flag. This command will generate a coverage report detailing statements, misses, and the overall coverage percentage. ```console pytest --cov=fiscalyear ``` -------------------------------- ### Temporarily Change Fiscal Calendar with Context Manager Source: https://github.com/adamjstewart/fiscalyear/blob/main/docs/advanced_usage.md Utilizes the `fiscal_calendar` context manager to temporarily alter the fiscal calendar settings for a specific block of code. Changes revert automatically upon exiting the context. ```python >>> from fiscalyear import * >>> a = FiscalYear(2017) >>> a.start FiscalDateTime(2016, 10, 1, 0, 0) >>> with fiscal_calendar(start_month=6): ... a.start ... FiscalDateTime(2016, 6, 1, 0, 0) >>> a.start FiscalDateTime(2016, 10, 1, 0, 0) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.