Learn R Programming

bsts (version 0.9.5)

to.posixt: Convert to POSIXt

Description

Convert an object of class Date to class POSIXct without getting bogged down in timezone calculation.

Usage

DateToPOSIX(timestamps)
  YearMonToPOSIX(timestamps)

Arguments

timestamps

An object of class yearmon or Date to be converted to POSIXct.

Details

Calling as.POSIXct on another date/time object (e.g. Date) applies a timezone correction to the object. This can shift the time marker by a few hours, which can have the effect of shifting the day by one unit. If the day was the first or last in a month or year, then the month or year will be off by one as well.

Coercing the object to the character representation of a Date prevents this adjustment from being applied, and leaves the POSIXt return value with the intended day, month, and year.