{"id":7228,"library":"fiscalyear","title":"FiscalYear","description":"FiscalYear is a small, lightweight Python module (current version 0.4.0) that provides utilities for managing the fiscal calendar. It extends Python's built-in `datetime` and `calendar` modules, enabling users to query the fiscal year, quarter, month, and day for any given date or datetime object. The project sees releases periodically, including bug fixes, new features, and occasional breaking changes to improve functionality and maintainability.","status":"active","version":"0.4.0","language":"en","source_language":"en","source_url":"https://github.com/adamjstewart/fiscalyear","tags":["fiscal calendar","date","time","finance","accounting","business"],"install":[{"cmd":"pip install fiscalyear","lang":"bash","label":"PyPI (Recommended)"},{"cmd":"conda install -c conda-forge fiscalyear","lang":"bash","label":"Anaconda/Conda"}],"dependencies":[],"imports":[{"symbol":"FiscalYear","correct":"from fiscalyear import FiscalYear"},{"symbol":"FiscalQuarter","correct":"from fiscalyear import FiscalQuarter"},{"symbol":"FiscalMonth","correct":"from fiscalyear import FiscalMonth"},{"symbol":"FiscalDay","correct":"from fiscalyear import FiscalDay"},{"symbol":"FiscalDate","correct":"from fiscalyear import FiscalDate"},{"symbol":"setup_fiscal_calendar","correct":"from fiscalyear import setup_fiscal_calendar"},{"symbol":"fiscal_calendar","correct":"from fiscalyear import fiscal_calendar"}],"quickstart":{"code":"import datetime\nfrom fiscalyear import FiscalYear, FiscalDate, setup_fiscal_calendar, fiscal_calendar\n\n# Set fiscal year to start in July globally\nsetup_fiscal_calendar(start_month=7)\n\n# Get current fiscal year information\ncurrent_fy = FiscalYear.current()\nprint(f\"Current Fiscal Year: {current_fy.year}\")\nprint(f\"FY Start: {current_fy.start.date()}, FY End: {current_fy.end.date()}\")\n\n# Get fiscal info for a specific date\nsome_date = datetime.date(2024, 11, 15)\nf_date = FiscalDate(some_date.year, some_date.month, some_date.day)\nprint(f\"\\nDate: {f_date}\")\nprint(f\"Fiscal Year: {f_date.fiscal_year}\")\nprint(f\"Fiscal Quarter: {f_date.fiscal_quarter}\")\nprint(f\"Fiscal Month: {f_date.fiscal_month}\")\n\n# Temporarily change fiscal calendar using context manager\nwith fiscal_calendar(start_month=4):\n    temp_f_date = FiscalDate(2024, 11, 15)\n    print(f\"\\nInside context manager (April start) for {temp_f_date}:\")\n    print(f\"Temporary Fiscal Year: {temp_f_date.fiscal_year}\")\n    print(f\"Temporary Fiscal Quarter: {temp_f_date.fiscal_quarter}\")\n\n# Outside context manager, global setting (July start) is restored\nprint(f\"\\nOutside context manager: Fiscal Year for {f_date}: {f_date.fiscal_year}\")","lang":"python","description":"This quickstart demonstrates how to initialize `fiscalyear`, globally set a custom fiscal year start month using `setup_fiscal_calendar`, and retrieve fiscal information for specific dates. It also shows the use of the `fiscal_calendar` context manager for temporary fiscal calendar adjustments without affecting global settings."},"warnings":[{"fix":"Use `fiscal_quarter`, `prev_fiscal_quarter`, and `next_fiscal_quarter` instead.","message":"The methods `quarter`, `prev_quarter`, and `next_quarter` were deprecated in v0.3.0 and completely removed in v0.4.0. Using them will result in an `AttributeError`.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Ensure your project runs on Python 3.6+ or downgrade `fiscalyear` to version 0.3.2 for Python 2 compatibility.","message":"Python 2 support was dropped in `fiscalyear` v0.4.0. The library now requires Python 3.6 or newer.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Always pass integer values for year, month, and day parameters.","message":"As of v0.4.0, many classes and functions that previously accepted 'int-like strings' for date components (e.g., '10' for October) now strictly require `int` types. Providing strings will lead to `TypeError` or `ValueError`.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Use `fiscalyear.setup_fiscal_calendar()` to globally configure the fiscal calendar or `with fiscalyear.fiscal_calendar():` context manager for temporary changes.","message":"Direct modification of `fiscalyear` global variables (e.g., `fiscalyear.START_MONTH = 7`) is discouraged and may lead to issues or be removed in future releases. It can also cause unexpected behavior in multi-threaded environments or when working with multiple fiscal calendars.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Pass the year, month, and day as separate integer arguments: `FiscalDate(my_datetime_obj.year, my_datetime_obj.month, my_datetime_obj.day)`.","cause":"Attempting to pass a `datetime.datetime` or `datetime.date` object directly to `FiscalDate()` instead of its constituent year, month, and day components.","error":"TypeError: FiscalDate() takes 3 positional arguments but 4 were given"},{"fix":"Replace `object.quarter` with `object.fiscal_quarter`. For previous/next, use `prev_fiscal_quarter` and `next_fiscal_quarter`.","cause":"Using the deprecated `quarter` attribute or method, which was removed in version 0.4.0.","error":"AttributeError: module 'fiscalyear' has no attribute 'quarter'"},{"fix":"Ensure `setup_fiscal_calendar` is called early in your application's lifecycle, preferably before any `FiscalYear` or `FiscalDate` objects are instantiated. Double-check the `start_year`, `start_month`, and `start_day` parameters. For temporary changes, use the `fiscal_calendar` context manager.","cause":"While a specific bug related to `fiscal_month` and `START_DAY` was fixed in v0.3.2, user reports indicate ongoing issues or confusion with `setup_fiscal_calendar`'s application, potentially due to incorrect usage or interaction with other settings.","error":"The fiscalyear.setup_fiscal_calendar(start_month=X) does not correctly apply the start month, resulting in incorrect fiscal year/quarter calculations."}]}