hip: Hours in Period

Description Usage Arguments Value Author(s) See Also Examples

View source: R/hip.R

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

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

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.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## 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 March 13, 2020, 2:23 a.m.