Skip to contents

Computes the first/last day in a given month/quarter.

Usage

timeFirstDayInMonth(charvec, format = "%Y-%m-%d", zone = "", 
    FinCenter = "")
timeLastDayInMonth(charvec, format = "%Y-%m-%d", zone = "", 
    FinCenter = "")

timeFirstDayInQuarter(charvec, format = "%Y-%m-%d", zone = "", 
    FinCenter = "")
timeLastDayInQuarter(charvec, format = "%Y-%m-%d", zone = "", 
    FinCenter = "")

Arguments

charvec

a character vector of dates and times.

format

the format specification of the input character vector.

zone

the time zone or financial center where the data were recorded.

FinCenter

a character with the location of the financial center named as "continent/city".

Details

The functions timeLastDayInMonth and timeLastDayInMonth return the last or first day, respectively, in a given month and year.

The same functionality for quarterly time horizons is returned by the functions timeLastDayInQuarter and timeLastDayInQuarter.

Value

an object of class "timeDate"

Examples

## Date as character String:
   charvec = "2006-04-16"
   myFinCenter = getRmetricsOptions("myFinCenter")

## timeLastDayInMonth-
   # What date has the last day in a month for a given date ?
   timeLastDayInMonth(charvec, format = "%Y-%m-%d", 
     zone = myFinCenter, FinCenter = myFinCenter)
#> GMT
#> [1] [2006-04-30]
   timeLastDayInMonth(charvec)
#> GMT
#> [1] [2006-04-30]
   timeLastDayInMonth(charvec, FinCenter = "Zurich")
#> Zurich
#> [1] [2006-04-30 02:00:00]
   
## timeFirstDayInMonth -
   # What date has the first day in a month for a given date ?
   timeFirstDayInMonth(charvec)
#> GMT
#> [1] [2006-04-01]
    
## timeLastDayInQuarter -
   # What date has the last day in a quarter for a given date ?
   timeLastDayInQuarter(charvec)
#> GMT
#> [1] [2006-06-30]
    
## timeFirstDayInQuarter -
   # What date has the first day in a quarter for a given date ?
   timeFirstDayInQuarter(charvec)
#> GMT
#> [1] [2006-04-01]
    
## timeNdayOnOrAfter
   # What date has the first Monday on or after March 15, 1986 ?
   timeNdayOnOrAfter("1986-03-15", 1)
#> GMT
#> [1] [1986-03-17]
    
## timeNdayOnOrBefore
   # What date has Friday on or before April 22, 1977 ?
   timeNdayOnOrBefore("1986-03-15", 5)
#> GMT
#> [1] [1986-03-14]
    
## timeNthNdayInMonth -
   # What date is the second Monday in April 2004 ?
   timeNthNdayInMonth("2004-04-01", 1, 2)
#> GMT
#> [1] [2004-04-12]
    
## timeLastNdayInMonth -
   # What date has the last Tuesday in May, 1996 ?
   timeLastNdayInMonth("1996-05-01", 2)
#> GMT
#> [1] [1996-05-28]