% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/coercion.r
\name{as.duration}
\alias{as.duration}
\alias{as.duration,numeric-method}
\alias{as.duration,logical-method}
\alias{as.duration,difftime-method}
\alias{as.duration,Interval-method}
\alias{as.duration,Duration-method}
\alias{as.duration,Period-method}
\alias{as.duration,character-method}
\title{Change an object to a duration}
\usage{
as.duration(x, ...)
}
\arguments{
\item{x}{Object to be coerced to a duration}

\item{...}{Parameters passed to other methods. Currently unused.}
}
\value{
A duration object
}
\description{
as.duration changes Interval, Period and numeric class objects to
Duration objects. Numeric objects are changed to Duration objects
with the seconds unit equal to the numeric value.
}
\details{
Durations are exact time measurements, whereas periods are relative time
measurements. See \linkS4class{Period}. The length of a period depends
on when it occurs. Hence, a one to one mapping does not exist between
durations and periods. When used with a period object, as.duration provides
an inexact estimate of the length of the period; each time unit is assigned
its most common number of seconds. A period of one month is converted to
2628000 seconds (approximately 30.42 days). This ensures that 12 months will
sum to 365 days, or one normal year. For an exact transformation, first
transform the period to an interval with \code{\link[=as.interval]{as.interval()}}.
}
\examples{
span <- interval(ymd("2009-01-01"), ymd("2009-08-01")) # interval
as.duration(span)
as.duration(10) # numeric
dur <- duration(hours = 10, minutes = 6)
as.numeric(dur, "hours")
as.numeric(dur, "minutes")
}
\seealso{
\linkS4class{Duration}, \code{\link[=duration]{duration()}}
}
\keyword{chron}
\keyword{classes}
\keyword{manip}
\keyword{methods}
