All Projects → tidyverse → Hms

tidyverse / Hms

Licence: other
A simple class for storing time-of-day values

Programming Languages

r
7636 projects

Labels

Projects that are alternatives of or similar to Hms

Timezone Support
Lightweight time zone support for your applications or other date libraries.
Stars: ✭ 90 (-23.08%)
Mutual labels:  time
Date And Time
A Minimalist DateTime utility for Node.js and the browser
Stars: ✭ 99 (-15.38%)
Mutual labels:  time
Timesincetextview
Android TextView for displaying the time since a date
Stars: ✭ 108 (-7.69%)
Mutual labels:  time
Tinytime
⏰ A straightforward date and time formatter in <1kb
Stars: ✭ 1,313 (+1022.22%)
Mutual labels:  time
Redux Time
∞ High-performance declarative JS animation library for building games, data-viz experiences, and more w/ React, ThreeJS, Inferno, SnabbDOM and others...
Stars: ✭ 99 (-15.38%)
Mutual labels:  time
Kairos
A non date-based time calculator
Stars: ✭ 100 (-14.53%)
Mutual labels:  time
News Record
目前主要维护经济学人【The Economist】、纽约客【The NewYorker】和时代杂志【Time】
Stars: ✭ 87 (-25.64%)
Mutual labels:  time
Human time
Ruby time and date comparisons for humans
Stars: ✭ 113 (-3.42%)
Mutual labels:  time
Cron4s
Cross-platform CRON expression parsing for Scala
Stars: ✭ 99 (-15.38%)
Mutual labels:  time
Hyperapp Fx
Effects for use with Hyperapp
Stars: ✭ 105 (-10.26%)
Mutual labels:  time
Luatz
Time, Date and Timezone library for lua
Stars: ✭ 92 (-21.37%)
Mutual labels:  time
Stopwatch
⏱️ Single-header C++11 RDTSCP clock and timing utilities released into the public domain.
Stars: ✭ 96 (-17.95%)
Mutual labels:  time
Timeoverflow
🏦 ⌛ A time banking system
Stars: ✭ 100 (-14.53%)
Mutual labels:  time
Js Joda
🕑 Immutable date and time library for javascript
Stars: ✭ 1,298 (+1009.4%)
Mutual labels:  time
Calendar
📅 PHP Date & Time library that solves common problems in object oriented, immutable way.
Stars: ✭ 113 (-3.42%)
Mutual labels:  time
Graphql Java Datetime
GraphQL ISO Date is a set of RFC 3339 compliant date/time scalar types to be used with graphql-java.
Stars: ✭ 89 (-23.93%)
Mutual labels:  time
Dateparse
GoLang Parse many date strings without knowing format in advance.
Stars: ✭ 1,365 (+1066.67%)
Mutual labels:  time
Use Timer
A timer hook for React
Stars: ✭ 113 (-3.42%)
Mutual labels:  time
Time
time是一个for typecho相册模板
Stars: ✭ 112 (-4.27%)
Mutual labels:  time
Time Stamp
Get a formatted timestamp. Used in gulp, assemble, generate, and many others.
Stars: ✭ 104 (-11.11%)
Mutual labels:  time

hms

Lifecycle: stable rcc codecov CRAN_Status_Badge

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

# 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.

library(hms)

hms(56, 34, 12)
#> 12:34:56
as_hms(Sys.time())
#> 11:55:02.553476
parse_hms("12:34:56")
#> 12:34:56
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

Internal representation

Objects of the hms and its underlying difftime classes are stored as number of seconds since 00:00:00. Use as.numeric() and as_hms() to convert to and from numbers.

times <- parse_hms(c("00:00:00.25", "00:00:01", "00:01:30", "01:00:00"))
times
#> 00:00:00.25
#> 00:00:01.00
#> 00:01:30.00
#> 01:00:00.00
times_num <- as.numeric(times)
times_num
#> [1]    0.25    1.00   90.00 3600.00
as_hms(times_num)
#> 00:00:00.25
#> 00:00:01.00
#> 00:01:30.00
#> 01:00:00.00

Please note that the ‘hms’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].