text_from_durationy: Format or print a 'durationy'

text_from_durationyR Documentation

Format or print a durationy

Description

A durationy is printed as a decimal.

This format is readable by durationy.character().

Usage

## S3 method for class 'durationy'
as.character(x, ...)

## S3 method for class 'durationy'
format(x, include_plus = FALSE, use_true_minus = TRUE, year_unit = "yr", ...)

## S3 method for class 'durationy'
print(
  x,
  include_plus = FALSE,
  use_true_minus = TRUE,
  year_unit = "yr",
  max = NULL,
  ...
)

Arguments

x

The durationy to print or format.

...

Other arguments.

include_plus

Whether to include a plus ('+') sign for positive durations. Defaults to FALSE.

use_true_minus

Whether to use the true minus sign ('-', U+2212) sign as opposed to the ASCII hyphen (-, U+002D). Defaults to TRUE.

year_unit

The year unit name to print. If not blank then the value is followed by a space and the unit. Cannot be more than 20 characters (UTF-8 bytes) or contain control characters. Defaults to "yr".

max

Numeric or NULL, specifying the maximal number of entries to be printed. When NULL, getOption("max.print") used. Defaults to NULL.

Value

as.character and format return a vector of character. print invisibly returns x.

See Also

durationy

Examples

pos <- durationy(1)
neg <- durationy(-2.3)
format(pos) # "1 yr"
format(pos, include_plus = TRUE) # "+1 yr"
format(pos, year_unit = "") # "1"
format(neg) # U+2212 (true minus) followed by "2.3" (CRAN-compliance)
format(neg, use_true_minus = FALSE) # "-2.3 yr"
format(neg, use_true_minus = FALSE, year_unit = "a") # "-2.3 a"

datey documentation built on July 14, 2026, 5:06 p.m.