Operations between Terms with different units need a daycount to convert them: one year has 252 days with business/252 and 360 days with actual/360. with_daycount() evaluates expr with the given daycount, so arithmetic and comparison between Terms with different units work. The Terms are converted to the smallest unit among them (years to months, months to days). Outside with_daycount() these operations raise an error.

with_daycount(x, expr)

Arguments

x

a Daycount object or a string, like "business/252".

expr

the expression to evaluate.

Value

the value of expr.

Examples

with_daycount("business/252", term(1, "month") + term(12, "days"))
#> [1] "33 days"
with_daycount("business/252", term(252, "days") == term(1, "year"))
#> [1] TRUE
with_daycount("actual/360", term(252, "days") == term(1, "year"))
#> [1] FALSE