Nicely print a year in a given format

nice_year(x, year_format)

Arguments

x

A year variable

year_format

The current format of x, one of "fyear6", "fyear4", "cyear2"

Value

A string formatted year

Examples

x <- 201516
nice_year(x, "fyear6")
#> [1] "2015/16"
nice_year(97, "cyear2")
#> [1] "1997"
nice_year(12, "cyear2")
#> [1] "2012"
nice_year("0708", "fyear4") # this fails - is it supposed to?
#> [1] "2007/08"
nice_year("07/08", "fyear4")
#> [1] "2007/08"