hip: Hours in Period

View source: R/hip.R

hipR Documentation

Hours in Period

Description

Given any starting and ending date/time objects, it generates:
1) a vector of class c("POSIXct" "POSIXt") with all the hours between the two date/time objects (both of them included), OR
2) the amount of hours between the two date/time objects

Usage

hip(from, to, date.fmt="%Y-%m-%d %H", out.type = "seq", tz="UTC")

Arguments

from

Character or POSIXct object indicating the starting date/time for creating the sequence. It has to be in the format indicated by date.fmt.

to

Character indicating the ending date/time for creating the sequence. It has to be in the format indicated by date.fmt.

date.fmt

character indicating the format in which the date/time objects are stored in from and to, e.g. %Y-%m-%d %H:%M. See format in as.Date.
ONLY required when class(dates)=="factor" or class(dates)=="numeric".

out.type

Character indicating the type of result that is given by this function. Valid values are:
1) seq : a vector of class Date with all the days between the two dates, OR
2) nmbr: a single numeric value with the amount of days between the two dates.

tz

specification of the desired time zone yo be used. System-specific (see time zones), but "" is the current time zone, and "GMT" (the default value) is UTC (Universal Time, Coordinated). See Sys.timezone and as.POSIXct.
This argument can be used when working with subdaily zoo objects to force using the local time zone instead of GMT as time zone.

Value

Depending on the value of out.type, it returns:
1) a vector of class c("POSIXct" "POSIXt") with all the hours between from and to (both of them included), OR
2) the amount of hours between the two date/time objects

Author(s)

Mauricio Zambrano-Bigiarini, mzb.devel@gmail

See Also

dip, mip, yip, diy, timeBasedSeq

Examples

## Sequence of hours between "1961-01-01 00:00" and "1961-01-10 00:00", giving the
## starting and ending date/time objects with hours and skipping the minutes (default)
hip("1961-01-01 00", "1961-12-31 00")

## Sequence of hours between "1961-01-01 00:00" and "1961-01-10 00:00", giving the
## starting and ending date/time objects only with hours and minutes(skipping the minutes)
hip("1961-01-01 00:00", "1961-12-31 00:00", date.fmt="%Y-%m-%d %H:%M")

## Number of hours between the 10:00 AM of "1961-Jan-02" and the 11:00 AM of "1961-Jan-01", 
## using "%d/%m/%Y" as date/time format.
hip("01/01/1961 10", "02/01/1961 11", date.fmt= "%d/%m/%Y %H", out.type = "nmbr")


hydroTSM documentation built on Nov. 4, 2024, 5:07 p.m.