Learn R Programming

shide (version 0.2.1)

sh_round: Round Jalali dates to a specific unit of time

Description

  • sh_floor() takes a jdate object and rounds it down to the previous unit of time.

  • sh_ceiling() takes a jdate object and rounds it up to the next unit of time.

  • sh_round() takes a jdate object and and rounds it up or down, depending on what is closer. For dates which are exactly halfway between two consecutive units, the convention is to round up.

Usage

sh_round(x, unit = NULL, ...)

sh_floor(x, unit = NULL, ...)

sh_ceiling(x, unit = NULL, ...)

Value

A vector of jdate objects with the same length as x.

Arguments

x

A vector of jdate objects.

unit

A scalar character, containing a date unit or a multiple of a unit. Valid date units are "day", "week", "month", "quarter" and "year". These can optionally be followed by "s". If multiple of a unit is used, unit coefficient must be a whole number greater than or equal to 1. If NULL, defaults to "day".

...

These dots are for future extensions and must be empty.

See Also

Examples

Run this code
x <- jdate("1402-12-15")
sh_floor(x, "year")
sh_floor(x, "2 months")
sh_ceiling(x, "year")
sh_round(x, "year")
sh_round(x, "week") == sh_floor(x, "week")
sh_round(x + 1, "week") == sh_ceiling(x, "week")

Run the code above in your browser using DataLab