1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/coercion.r
3\name{as.duration}
4\alias{as.duration}
5\alias{as.duration,numeric-method}
6\alias{as.duration,logical-method}
7\alias{as.duration,difftime-method}
8\alias{as.duration,Interval-method}
9\alias{as.duration,Duration-method}
10\alias{as.duration,Period-method}
11\alias{as.duration,character-method}
12\title{Change an object to a duration}
13\usage{
14as.duration(x, ...)
15}
16\arguments{
17\item{x}{Object to be coerced to a duration}
18
19\item{...}{Parameters passed to other methods. Currently unused.}
20}
21\value{
22A duration object
23}
24\description{
25as.duration changes Interval, Period and numeric class objects to
26Duration objects. Numeric objects are changed to Duration objects
27with the seconds unit equal to the numeric value.
28}
29\details{
30Durations are exact time measurements, whereas periods are relative time
31measurements. See \linkS4class{Period}. The length of a period depends
32on when it occurs. Hence, a one to one mapping does not exist between
33durations and periods. When used with a period object, as.duration provides
34an inexact estimate of the length of the period; each time unit is assigned
35its most common number of seconds. A period of one month is converted to
362628000 seconds (approximately 30.42 days). This ensures that 12 months will
37sum to 365 days, or one normal year. For an exact transformation, first
38transform the period to an interval with \code{\link[=as.interval]{as.interval()}}.
39}
40\examples{
41span <- interval(ymd("2009-01-01"), ymd("2009-08-01")) #interval
42as.duration(span)
43as.duration(10) # numeric
44dur <- duration(hours = 10, minutes = 6)
45as.numeric(dur, "hours")
46as.numeric(dur, "minutes")
47
48}
49\seealso{
50\linkS4class{Duration}, \code{\link[=duration]{duration()}}
51}
52\keyword{chron}
53\keyword{classes}
54\keyword{manip}
55\keyword{methods}
56