% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/timeRange.R
\name{timeRange}
\alias{timeRange}
\title{Create a POSIXct time range}
\usage{
timeRange(
  starttime = NULL,
  endtime = NULL,
  timezone = NULL,
  unit = "sec",
  ceilingStart = FALSE,
  ceilingEnd = FALSE
)
}
\arguments{
\item{starttime}{Desired start datetime.}

\item{endtime}{Desired end datetime.}

\item{timezone}{Olson timezone used to interpret incoming datetimes.}

\item{unit}{Unit used for rounding. Passed to \code{\link[lubridate:round_date]{lubridate::floor_date()}} or
\code{\link[lubridate:round_date]{lubridate::ceiling_date()}}.}

\item{ceilingStart}{Logical specifying whether to round the start time up
instead of down.}

\item{ceilingEnd}{Logical specifying whether to round the end time up instead
of down.}
}
\value{
Two-element \code{POSIXct} vector ordered from earliest to latest.
}
\description{
Create an ordered two-element \code{POSIXct} time range from start and end
datetime values.
}
\details{
Input values are converted with \code{\link[=parseDatetime]{parseDatetime()}} using the required
\code{timezone} argument. The resulting start and end times are sorted so the
earlier time is always returned first.

By default, both times are rounded down with \code{\link[lubridate:round_date]{lubridate::floor_date()}} using
the requested \code{unit}. Set \code{ceilingStart = TRUE} or \code{ceilingEnd = TRUE} to
round either endpoint up with \code{\link[lubridate:round_date]{lubridate::ceiling_date()}} instead.
}
\section{POSIXct inputs}{

When \code{startdate} or \code{enddate} are already \code{POSIXct} values, they are first
converted to \code{timezone} with \code{\link[lubridate:with_tz]{lubridate::with_tz()}} without changing the
represented instant in time.
}

\examples{
timeRange(
  starttime = "2019-01-08 10:12:15",
  endtime = 20190109102030,
  timezone = "UTC"
)

timeRange(
  starttime = "2019-01-08 10:12:15",
  endtime = "2019-01-09 10:20:30",
  timezone = "UTC",
  unit = "hour"
)

}
