luxon-financial-year-data
v1.2.0
Published
Luxon financial year date ranges
Downloads
46
Maintainers
Readme
luxon-financial-year-data
This package provides easy way to get days, weeks, months and quarters for a given fiscal (financial) year as well as list of fiscal years (past and future) for a given country (using ISO code).
Features
Returns list of days within a given fiscal year
Returns list of weeks (week starts from Monday and ends on Sunday) within a given fiscal year
Returns list of months within a given fiscal year
Returns list of quarters within a given fiscal year
Returns n number of past or future fiscal years for a given country code
Download/Install
npm i luxon-financial-year-data
Methods/Options
- Get Days/Weeks/Months/Quarters within a fiscal year
getFiscalYearDateRanges(year, month, day, type, outputFormat);
- year = Numeric representation of start of a fiscal year
- month = Month of beginning of fiscal year
- day = Day of beginning of fiscal year
- type = Type of output expected. Valid values are "DAYS", "WEEKS", "MONTHS", "QUARTERS". Defaults to sending empty list.
- outputFormat = Output format for the result. Valid values are "MILLIS", "OBJECT", "LOCALE", "ISO", "JSON". Defaults to JS Object.
- Get N past or future fiscal years for a given country code
getFiscalYearsForGivenCountry(countryISOCode, type, years, outputFormat);
- countryISOCode = Alpha 2 ISO 3166 country codes
- type = "FUTURE", "PAST". FUTURE gives fiscal years in future from current year and PAST gives fiscal years in past from current year.
- years = Numeric value of number of past/future fiscal years needed.
- outputFormat = Output format for the result. Valid values are "MILLIS", "OBJECT", "LOCALE", "ISO", "JSON". Defaults to JS Object.
Examples
- Get list of days in a fiscal year in milliseconds
const { getFiscalYearDateRanges } = require('luxon-financial-year-data');
let fiscalDays = getFiscalYearDateRanges(2021, 04, 01, "DAYS", "MILLIS");
- Get list of months in a fiscal year in locale format
const { getFiscalYearDateRanges } = require('luxon-financial-year-data');
let fiscalMonths = getFiscalYearDateRanges(2021, 04, 01, "MONTHS", "LOCALE");
- Get list of quarters in a fiscal year in ISO format
const { getFiscalYearDateRanges } = require('luxon-financial-year-data');
let fiscalMonths = getFiscalYearDateRanges(2021, 04, 01, "QUARTERS", "LOCALE");
- Get next (FUTURE) 5 fiscal years for US (United States)
const { getFiscalYearsForGivenCountry } = require('luxon-financial-year-data');
let fyList = getFiscalYearsForGivenCountry("US", "FUTURE", 5, "LOCALE");
- Get previous (PAST) 10 fiscal years for AU (Australia)
const { getFiscalYearsForGivenCountry } = require('luxon-financial-year-data');
let fyList = getFiscalYearsForGivenCountry("AU", "PAST", 10, "LOCALE");