hms/ 0000755 0001762 0000144 00000000000 13605457502 011050 5 ustar ligges users hms/NAMESPACE 0000644 0001762 0000144 00000002713 13605127176 012273 0 ustar ligges users # Generated by roxygen2: do not edit by hand
S3method("[<-",hms)
S3method("[[",hms)
S3method("units<-",hms)
S3method(as.POSIXct,hms)
S3method(as.POSIXlt,hms)
S3method(as.character,hms)
S3method(as.hms,POSIXlt)
S3method(as.hms,POSIXt)
S3method(as.hms,default)
S3method(c,hms)
S3method(format,hms)
S3method(print,hms)
S3method(vec_cast,hms)
S3method(vec_cast.POSIXct,hms)
S3method(vec_cast.POSIXlt,hms)
S3method(vec_cast.character,hms)
S3method(vec_cast.difftime,hms)
S3method(vec_cast.double,hms)
S3method(vec_cast.hms,POSIXct)
S3method(vec_cast.hms,POSIXlt)
S3method(vec_cast.hms,character)
S3method(vec_cast.hms,default)
S3method(vec_cast.hms,difftime)
S3method(vec_cast.hms,double)
S3method(vec_cast.hms,hms)
S3method(vec_cast.hms,integer)
S3method(vec_cast.integer,hms)
S3method(vec_ptype2,hms)
S3method(vec_ptype2.character,hms)
S3method(vec_ptype2.difftime,hms)
S3method(vec_ptype2.double,hms)
S3method(vec_ptype2.hms,character)
S3method(vec_ptype2.hms,default)
S3method(vec_ptype2.hms,difftime)
S3method(vec_ptype2.hms,double)
S3method(vec_ptype2.hms,hms)
S3method(vec_ptype2.hms,integer)
S3method(vec_ptype2.integer,hms)
S3method(vec_ptype_abbr,hms)
S3method(vec_ptype_full,hms)
export(as.hms)
export(as_hms)
export(hms)
export(is.hms)
export(is_hms)
export(new_hms)
export(parse_hm)
export(parse_hms)
export(round_hms)
export(trunc_hms)
export(vec_cast.hms)
export(vec_ptype2.hms)
import(rlang)
import(vctrs)
importFrom(methods,setOldClass)
importFrom(pkgconfig,get_config)
hms/README.md 0000644 0001762 0000144 00000004706 13511055774 012337 0 ustar ligges users
# hms
[](https://www.tidyverse.org/lifecycle/#maturing)
[](https://travis-ci.org/tidyverse/hms)
[](https://ci.appveyor.com/project/tidyverse/hms)
[](https://codecov.io/gh/tidyverse/hms)
[](https://cran.r-project.org/package=hms)
## Overview
The hms package provides a simple class for storing durations or
time-of-day values and displaying them in the hh:mm:ss format. This
class is intended to simplify data exchange with databases,
spreadsheets, and other data sources:
- Stores values as a numeric vector that contains the number of
seconds since midnight
- Supports construction from explicit hour, minute, or second values
- Supports coercion to and from various data types, including `POSIXt`
- Can be used as column in a data frame
- Based on the `difftime` class
- Values can exceed the 24-hour boundary or be negative
- By default, fractional seconds up to a microsecond are displayed,
regardless of the value of the `"digits.secs"` option
## Installation
``` r
# The easiest way to get hms is to install the whole tidyverse:
install.packages("tidyverse")
# Alternatively, install just hms:
install.packages("hms")
# Or the the development version from GitHub:
# install.packages("devtools")
devtools::install_github("tidyverse/hms")
```
## Usage
The following example showcases ways of using the `hms` class standalone
or as a data frame column.
``` r
library(hms)
hms(56, 34, 12)
#> 12:34:56
as_hms(1)
#> 00:00:01
as_hms("12:34:56")
#> 12:34:56
as_hms(Sys.time())
#> 11:18:52.496955
as.POSIXct(hms(1))
#> [1] "1970-01-01 00:00:01 UTC"
data.frame(hours = 1:3, hms = hms(hours = 1:3))
#> hours hms
#> 1 1 01:00:00
#> 2 2 02:00:00
#> 3 3 03:00:00
```
-----
Please note that the ‘hms’ project is released with a [Contributor Code
of
Conduct](https://github.com/tidyverse/hms/blob/master/CODE_OF_CONDUCT.md).
By contributing to this project, you agree to abide by its terms.
hms/man/ 0000755 0001762 0000144 00000000000 13602661175 011623 5 ustar ligges users hms/man/vec_cast.hms.Rd 0000644 0001762 0000144 00000001101 13502523706 014454 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cast.R
\name{vec_cast.hms}
\alias{vec_cast.hms}
\title{Casting}
\usage{
\method{vec_cast}{hms}(x, to, ...)
}
\arguments{
\item{x}{Vectors to cast.}
\item{to}{Type to cast to. If \code{NULL}, \code{x} will be returned as is.}
\item{...}{For \code{vec_cast_common()}, vectors to cast. For
\code{vec_cast()} and \code{vec_restore()}, these dots are only for future
extensions and should be empty.}
}
\description{
Double dispatch methods to support \code{\link[vctrs:vec_cast]{vctrs::vec_cast()}}.
}
hms/man/hms-package.Rd 0000644 0001762 0000144 00000001450 13602661203 014262 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hms.R
\docType{package}
\name{hms-package}
\alias{hms-package}
\title{hms: Pretty Time of Day}
\description{
\if{html}{\figure{logo.png}{options: align='right' alt='logo' width='120'}}
Implements an S3 class for storing and formatting time-of-day
values, based on the 'difftime' class.
}
\details{
\Sexpr[results=rd, stage=render]{hms:::lifecycle("stable")}
}
\seealso{
Useful links:
\itemize{
\item \url{https://hms.tidyverse.org/}
\item \url{https://github.com/tidyverse/hms}
\item Report bugs at \url{https://github.com/tidyverse/hms/issues}
}
}
\author{
\strong{Maintainer}: Kirill Müller \email{krlmlr+r@mailbox.org}
Other contributors:
\itemize{
\item The R Consortium [funder]
\item RStudio [funder]
}
}
hms/man/hms.Rd 0000644 0001762 0000144 00000004147 13602662754 012713 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hms.R
\name{hms}
\alias{hms}
\alias{new_hms}
\alias{is_hms}
\alias{as_hms}
\alias{as.POSIXct.hms}
\alias{as.POSIXlt.hms}
\alias{as.character.hms}
\alias{format.hms}
\alias{print.hms}
\title{A simple class for storing time-of-day values}
\usage{
hms(seconds = NULL, minutes = NULL, hours = NULL, days = NULL)
new_hms(x = numeric())
is_hms(x)
as_hms(x)
\method{as.POSIXct}{hms}(x, ...)
\method{as.POSIXlt}{hms}(x, ...)
\method{as.character}{hms}(x, ...)
\method{format}{hms}(x, ...)
\method{print}{hms}(x, ...)
}
\arguments{
\item{seconds, minutes, hours, days}{Time since midnight. No bounds checking is
performed.}
\item{x}{An object.}
\item{...}{additional arguments to be passed to or from methods.}
}
\description{
The values are stored as a \link{difftime} vector with a custom class,
and always with "seconds" as unit for robust coercion to numeric.
Supports construction from time values, coercion to and from
various data types, and formatting. Can be used as a regular column in a
data frame.
\code{hms()} is a high-level constructor that accepts second, minute, hour and day components
as numeric vectors.
\code{new_hms()} is a low-level constructor that only checks that its input has the correct base type, \link{numeric}.
\code{is_hms()} checks if an object is of class \code{hms}.
\code{as_hms()} forwards to \code{\link[=vec_cast]{vec_cast()}}.
}
\details{
For \code{hms}, all arguments must have the same length or be
\code{NULL}. Odd combinations (e.g., passing only \code{seconds} and
\code{hours} but not \code{minutes}) are rejected.
For arguments of type \link{POSIXct} and \link{POSIXlt}, \code{as_hms()} does not perform timezone
conversion.
Use \code{\link[lubridate:with_tz]{lubridate::with_tz()}} and \code{\link[lubridate:force_tz]{lubridate::force_tz()}} as necessary.
}
\examples{
hms(56, 34, 12)
hms()
new_hms(as.numeric(1:3))
# Supports numeric only!
try(new_hms(1:3))
as_hms(1)
as_hms("12:34:56")
as_hms(Sys.time())
as.POSIXct(hms(1))
data.frame(a = hms(1))
d <- data.frame(hours = 1:3)
d$hours <- hms(hours = d$hours)
d
}
hms/man/vec_ptype2.hms.Rd 0000644 0001762 0000144 00000001615 13602661203 014753 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/coerce.R
\name{vec_ptype2.hms}
\alias{vec_ptype2.hms}
\title{Coercion}
\usage{
\method{vec_ptype2}{hms}(x, y, ..., x_arg = "", y_arg = "")
}
\arguments{
\item{x}{Vector types.}
\item{y}{Vector types.}
\item{...}{These dots are for future extensions and must be empty.}
\item{x_arg}{Argument names for \code{x} and \code{y}. These are used
in error messages to inform the user about the locations of
incompatible types (see \code{\link[vctrs:stop_incompatible_type]{stop_incompatible_type()}}).}
\item{y_arg}{Argument names for \code{x} and \code{y}. These are used
in error messages to inform the user about the locations of
incompatible types (see \code{\link[vctrs:stop_incompatible_type]{stop_incompatible_type()}}).}
}
\description{
Double dispatch methods to support \code{\link[vctrs:vec_ptype2]{vctrs::vec_ptype2()}}.
}
hms/man/round_hms.Rd 0000644 0001762 0000144 00000001226 13562622301 014102 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/round.R
\name{round_hms}
\alias{round_hms}
\alias{trunc_hms}
\title{Round or truncate to a multiple of seconds}
\usage{
round_hms(x, secs)
trunc_hms(x, secs)
}
\arguments{
\item{x}{A vector of class \link{hms}}
\item{secs}{Multiple of seconds, a positive numeric. Values less than one
are supported}
}
\value{
The input, rounded or truncated to the nearest multiple of \code{secs}
}
\description{
Convenience functions to round or truncate to a multiple of seconds.
}
\examples{
round_hms(as_hms("12:34:56"), 5)
round_hms(as_hms("12:34:56"), 60)
trunc_hms(as_hms("12:34:56"), 60)
}
hms/man/Deprecated.Rd 0000644 0001762 0000144 00000002550 13602661203 014144 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hms.R
\name{Deprecated}
\alias{Deprecated}
\alias{is.hms}
\alias{as.hms}
\alias{as.hms.default}
\alias{as.hms.POSIXt}
\alias{as.hms.POSIXlt}
\title{Deprecated functions}
\usage{
is.hms(x)
as.hms(x, ...)
\method{as.hms}{default}(x, ...)
\method{as.hms}{POSIXt}(x, tz = pkgconfig::get_config("hms::default_tz", ""), ...)
\method{as.hms}{POSIXlt}(x, tz = pkgconfig::get_config("hms::default_tz", ""), ...)
}
\arguments{
\item{x}{An object.}
\item{...}{Arguments passed on to further methods.}
\item{tz}{The time zone in which to interpret a POSIXt time for extracting
the time of day. The default is now the zone of \code{x} but was \code{"UTC"}
for v0.3 and earlier. The previous behavior can be restored by calling
\code{pkgconfig::set_config("hms::default_tz", "UTC")}, see
\code{\link[pkgconfig:set_config]{pkgconfig::set_config()}}.}
}
\description{
\code{is.hms()} has been replaced by \code{\link[=is_hms]{is_hms()}}.
\code{as.hms()} has been replaced by \code{\link[=as_hms]{as_hms()}}, which is no longer generic and also
does not have a \code{tz} argument.
It also uses the time zone of the argument for conversion,
not the current system's timezone.
Change the timezone before converting if necessary, e.g. using \code{\link[lubridate:with_tz]{lubridate::with_tz()}}.
}
\keyword{internal}
hms/man/figures/ 0000755 0001762 0000144 00000000000 13452227404 013263 5 ustar ligges users hms/man/figures/lifecycle-defunct.svg 0000644 0001762 0000144 00000001704 13452227404 017373 0 ustar ligges users