time: Time Extraction and Conversion

View source: R/time.R

timeR Documentation

Time Extraction and Conversion

Description

These are convenience functions to extract a time field from an object, such as a character string or a data frame.

Usage

time(x, ...)

## Default S3 method:
time(x, date, time, year, month, day, hour = 0, minute = 0, second = 0, ...)

## S3 method for class 'logical'
time(x, ...)

## S3 method for class 'numeric'
time(x, ...)

## S3 method for class 'character'
time(x, ...)

## S3 method for class 'data.frame'
time(x, ...)

Arguments

x

Object.

...

Further arguments passed onto

date

Date object or formatted character string representing a date.

time

Time object or formatted character string representing a time.

year

Date year.

month

Date month.

day

Date day.

hour

Time hour.

minute

Time minute.

second

Time second.

Value

Generally a POSIXct or POSIXt object.

Methods (by class)

  • time(default): Default time method.

  • time(logical): Convert time from logical value.

  • time(numeric): Convert time from numeric value.

  • time(character): Convert time from character string.

  • time(data.frame): Extract time from data frame.

Examples

time() # Current time (base method).

# Equivalent nine o'clock specification:
time(9)
time("9")
time("9h")
time("9h00")
time("9:00")
time("9:00:00")

# All equivalent time strings:
time("194501")
time("19:45:01")
time("19h45m01")
time("19h45m01")


TobieSurette/gulf.utils documentation built on Dec. 1, 2024, 6:01 a.m.