Skip to contents

Utilities for working with financial years

Usage

financial_year(
  x = integer(),
  boundary = getOption("acadyr.financial_year_boundary", as.Date("2020-04-01"))
)

is_financial_year(x)

as_financial_year(
  x,
  boundary = getOption("acadyr.financial_year_boundary", as.Date("2020-04-01")),
  ...
)

Arguments

x
  • For financial_year(): A numeric vector

  • For as_financial_year(): An object to coerce

  • For is_financial_year(): An object to test

boundary

A boundary date where the new financial year should begin. Note that only the month/day of this date is used. This can be set using the global option acadyr.financial_year_boundary. E.g. to use financial years starting on January 1 (as used by Vietnam, the United Arab Emirates, Ukraine etc), use the following:

options(acadyr.financial_year_boundary = as.Date("2020-01-01"))

...

Passed on to methods

Value

  • For financial_year(): A <financial_year> vector

  • For as_financial_year(): A <financial_year> vector

  • For is_financial_year(): A <logical> vector

Examples

# Numbers are treated as if they represent years
financial_year(2005:2015)
#> <financial_year[11]>
#>  [1] 2005-06 2006-07 2007-08 2008-09 2009-10 2010-11 2011-12 2012-13 2013-14
#> [10] 2014-15 2015-16

# Dates are mapped to the year they fall within
dates <- as.Date(c("2020-03-01", "2020-05-01"))
financial_year(dates)
#> <financial_year[2]>
#> [1] 2019-20 2020-21

# The year they fall within depends on the year boundary, which
# defaults to April 01
financial_year(dates, boundary = as.Date("2020-01-01"))
#> <financial_year[2]>
#> [1] 2020-21 2020-21

# as_financial_year() also understands character vectors:
as_financial_year(c("2020-21", "2021-22"))
#> <financial_year[2]>
#> [1] 2020-21 2021-22