is_fy: Convenience functions for dealing with financial years

View source: R/fy_year.R

is_fyR Documentation

Convenience functions for dealing with financial years

Description

Convenience functions for dealing with financial years

Usage

yr2fy(
  yr_ending,
  assume1901_2100 = .getOption("fy.assume1901_2100",
    .getOption("grattan.assume1901_2100", TRUE))
)

.yr2fy(yr_ending)

fy2yr(x, validate = TRUE)

fy2date(x, validate = TRUE)

date2fy(date)

qtr2fy(yq)

Arguments

yr_ending

An integer representing a year.

assume1901_2100

For yr2fy, assume that yr_ending is between 1901 and 2100, for performance. By default, set to getOption("fy.assume1901_2100", TRUE).

x

A character vector suspected to be a financial year.

validate

If TRUE, the default, inputs that are expected to be financial years are first validated. Validation should be very fast, though some use-cases may require this be skipped.

date

A string or date for which the financial year is desired. Note that yr2fy does not check its argument is an integer.

yq

A character vector representing year quarters in 1066-Q2 format.

Details

See valid-fys for allowed forms of x.

Value

For is_fy, a logical, whether its argument is a financial year. The following forms are allowed: 2012-13, 201213, 2012 13, as well as 2012<dash>13 for some dash symbols. For fy.year, yr2fy, and date2fy, the financial year. For the inverses, a numeric corresponding to the year.

fy.year was an alias for yr2fy, and is now defunct.

fy2yr converts a financial year to the year ending: fy2yr("2016-17") returns 2017. yr2fy is the inverse: yr2fy(fy2yr("2016-17")) == "2016-17".

fy2date converts a financial year to the 30 June of the financial year ending.

date2fy converts a date to the corresponding financial year.

Examples

is_fy("2012-13")
is_fy("2012-14")
yr2fy(2012)
fy2yr("2015-16")
date2fy("2014-08-09")

fy documentation built on Sept. 12, 2023, 9:06 a.m.